Skip to main content

SlabDirectory

Struct SlabDirectory 

Source
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: Header

Decoded 20-byte fixed header.

§entries: Vec<SlabTableEntry>

One entry per slab, in slab-table order.

Implementations§

Source§

impl SlabDirectory

Source

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.

Source

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.

Source

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.

Source

pub fn root_json_index(&self) -> usize

Index of the slab that holds the root JSON skeleton.

Source

pub fn root_entry(&self) -> &SlabTableEntry

Slab-table entry for the root JSON skeleton slab.

Source

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).

Trait Implementations§

Source§

impl Clone for SlabDirectory

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SlabDirectory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.