Add Entry::field_type

The directory API offers a direct access to entries. It is useful for
downstream to have the ability of inspecting fields before consuming
them.
This commit is contained in:
A. Molzer committed 2025-07-13 01:11:59 +02:00
1 parent 3e530d27ea
commit 890488b16e
1 file changed
+7 -3
+7 -3
View File
@@ -350,9 +350,9 @@ impl ::std::fmt::Debug for Entry {
impl Entry {
pub fn new(type_: Type, count: u32, offset: [u8; 4]) -> Entry {
let mut offset = offset.to_vec();
offset.append(&mut vec![0; 4]);
Entry::new_u64(type_, count.into(), offset[..].try_into().unwrap())
let mut entry_off = [0u8; 8];
entry_off[..4].copy_from_slice(&offset);
Entry::new_u64(type_, count.into(), entry_off)
}
pub fn new_u64(type_: Type, count: u64, offset: [u8; 8]) -> Entry {
@@ -363,6 +363,10 @@ impl Entry {
}
}
pub fn field_type(&self) -> Type {
self.type_
}
pub fn count(&self) -> u64 {
self.count
}