pub struct SlabDirectory {
pub header: Header,
pub entries: Vec<SlabTableEntry>,
}Expand description
Low-level alternative to ParsedFile. A SlabDirectory consumes the entire
front-part of the file, including the header.
Fields§
§header: HeaderDecoded 20-byte fixed header.
entries: Vec<SlabTableEntry>One entry per slab, in slab-table order.
Implementations§
Source§impl SlabDirectory
impl SlabDirectory
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, ParseError>
pub fn parse(bytes: &[u8]) -> Result<Self, ParseError>
Parse the fixed header and slab table from the front of an
in-memory buffer. Payload bytes are not read or validated; call
SlabDirectory::validate_extents separately to check that
every slab body fits.
Sourcepub fn read<R: Read>(r: &mut R) -> Result<Self>
pub fn read<R: Read>(r: &mut R) -> Result<Self>
Read the fixed header and slab table from a stream. Advances
r by exactly FIXED_HEADER_SIZE + slab_count * SLAB_TABLE_ENTRY_SIZE bytes on success. Payload bytes are not
touched — the reader is left positioned at the first byte after
the slab table.
Header/table decode errors are surfaced as
io::ErrorKind::InvalidData.
Sourcepub fn validate_extents(&self, file_len: u64) -> Result<(), ParseError>
pub fn validate_extents(&self, file_len: u64) -> Result<(), ParseError>
Check that every slab’s [start_offset, start_offset + byte_length) range fits within a container of file_len bytes.
Sourcepub fn root_json_index(&self) -> usize
pub fn root_json_index(&self) -> usize
Index of the slab that holds the root JSON skeleton.
Sourcepub fn root_entry(&self) -> &SlabTableEntry
pub fn root_entry(&self) -> &SlabTableEntry
Slab-table entry for the root JSON skeleton slab.
Sourcepub fn header_and_table_size(&self) -> u64
pub fn header_and_table_size(&self) -> u64
Total byte size of the header + slab table (i.e. the byte offset at which slab payloads may start).