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>
impl<'a> Directory<'a>
Sourcepub fn parse(
header: &[u8],
footer: &'a [u8],
placement: Placement,
) -> Result<Self>
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.
Sourcepub fn parse_without_root_digest(
header: &[u8],
footer: &'a [u8],
placement: Placement,
) -> Result<Self>
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.
Sourcepub const fn header(&self) -> FileHeader
pub const fn header(&self) -> FileHeader
The format version this container was written at.
Sourcepub const fn root_digest(&self) -> Digest
pub const fn root_digest(&self) -> Digest
The digest that covers the header and the footer.
Sourcepub const fn decoder(&self) -> Option<&DecoderRef<'a>>
pub const fn decoder(&self) -> Option<&DecoderRef<'a>>
The decoder reference, if there is one.
Sourcepub fn decoder_section(&self) -> Option<&Section>
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.