Skip to main content

Directory

Struct Directory 

Source
pub struct Directory<'a> { /* private fields */ }
Expand description

What a container holds, without the bytes it holds.

Parsed from the header and the footer, so it borrows the footer and nothing else. A host that read those two ranges out of a file it is not holding has everything here that a host holding the whole file has, minus the ability to hand over a section’s bytes.

Implementations§

Source§

impl<'a> Directory<'a>

Source

pub fn parse( header: &[u8], footer: &'a [u8], placement: Placement, ) -> Result<Self>

Parses the metadata and checks that it is the metadata that was written.

header is the first HEADER_SIZE bytes of the file and footer is the Placement::footer_len bytes at Placement::footer_at. The root digest covers exactly those two ranges, so a directory that parses is one nobody has edited since it was written.

§Errors

Returns Error describing the first thing that was wrong, including Error::DigestMismatch if the bytes do not hash to the root digest in the trailer.

Source

pub fn parse_without_root_digest( header: &[u8], footer: &'a [u8], placement: Placement, ) -> Result<Self>

Parses the metadata without checking the root digest.

This exists for the fuzzer, for the same reason the container has one: checking the digest first would mean essentially every generated input is rejected before the parser behind it runs, and the parser is the part that needs the fuzzing.

§Errors

The same as Directory::parse, minus the digest mismatch.

Source

pub const fn header(&self) -> FileHeader

The format version this container was written at.

Source

pub const fn placement(&self) -> Placement

Where the footer is and how long the file is.

Source

pub const fn root_digest(&self) -> Digest

The digest that covers the header and the footer.

Source

pub const fn dataset(&self) -> &Dataset

What the dataset is.

Source

pub const fn schema(&self) -> Option<&Schema<'a>>

The schema, if there is one.

Source

pub const fn decoder(&self) -> Option<&DecoderRef<'a>>

The decoder reference, if there is one.

Source

pub fn sections(&self) -> &[Section]

Every section, in the order the footer listed them.

Source

pub fn section(&self, id: u32) -> Option<&Section>

The section with this id.

Source

pub fn decoder_section(&self) -> Option<&Section>

The section the decoder module is in, if the decoder is embedded and that section exists.

A host holding the whole file follows this with crate::Container::section_bytes. A host that is not holding the file reads the range itself, which is the only difference between the two paths and the reason this returns a section rather than bytes.

Trait Implementations§

Source§

impl<'a> Clone for Directory<'a>

Source§

fn clone(&self) -> Directory<'a>

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<'a> Debug for Directory<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Directory<'a>

§

impl<'a> RefUnwindSafe for Directory<'a>

§

impl<'a> Send for Directory<'a>

§

impl<'a> Sync for Directory<'a>

§

impl<'a> Unpin for Directory<'a>

§

impl<'a> UnsafeUnpin for Directory<'a>

§

impl<'a> UnwindSafe for Directory<'a>

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.