/// # Safety /// /// `buf` must contain a `soffset_t` at `loc`, which points to a valid vtable #[inline] pubunsafefn new(buf: &'a [u8], loc: usize) -> Self {
Table { buf, loc }
}
#[inline] pubfn vtable(&self) -> VTable<'a> { // Safety: // Table::new is created with a valid buf and location unsafe { <BackwardsSOffset<VTable<'a>>>::follow(self.buf, self.loc) }
}
/// Retrieves the value at the provided `slot_byte_loc` returning `default` /// if no value present /// /// # Safety /// /// The value of the corresponding slot must have type T #[inline] pubunsafefn get<T: Follow<'a> + 'a>(
&self,
slot_byte_loc: VOffsetT,
default: Option<T::Inner>,
) -> Option<T::Inner> { let o = self.vtable().get(slot_byte_loc) as usize; if o == 0 { return default;
}
Some(<T>::follow(self.buf, self.loc + o))
}
}
impl<'a> Follow<'a> for Table<'a> { type Inner = Table<'a>; #[inline] unsafefn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Table { buf, loc }
}
}
/// Returns true if data contains a prefix of `ident` #[inline] pubfn buffer_has_identifier(data: &[u8], ident: &str, size_prefixed: bool) -> bool {
assert_eq!(ident.len(), FILE_IDENTIFIER_LENGTH);
let got = if size_prefixed {
assert!(data.len() >= SIZE_SIZEPREFIX + SIZE_UOFFSET + FILE_IDENTIFIER_LENGTH); // Safety: // Verified data has sufficient bytes unsafe { <SkipSizePrefix<SkipRootOffset<FileIdentifier>>>::follow(data, 0) }
} else {
assert!(data.len() >= SIZE_UOFFSET + FILE_IDENTIFIER_LENGTH); // Safety: // Verified data has sufficient bytes unsafe { <SkipRootOffset<FileIdentifier>>::follow(data, 0) }
};
ident.as_bytes() == got
}
Messung V0.5 in Prozent
[zur Elbe Produktseite wechseln0.24QuellennavigatorsAnalyse erneut starten2026-08-25]