pub struct Placement { /* private fields */ }Expand description
Where the footer is, read from the trailer.
This is the first thing a host learns about a container and the only thing it can learn without being told where to look, because the trailer is at a known distance from the end. Everything else follows from it.
Implementations§
Source§impl Placement
impl Placement
Sourcepub const TRAILER_LEN: usize = TRAILER_SIZE
pub const TRAILER_LEN: usize = TRAILER_SIZE
How many bytes at the end of the file the trailer occupies.
Sourcepub fn trailer_at(file_len: u64) -> Result<u64>
pub fn trailer_at(file_len: u64) -> Result<u64>
Where the trailer starts in a file of this length.
§Errors
Error::Truncated if the file is too short to be a container at all, which is checked
here so that a host cannot be told to read from a negative offset.
Sourcepub fn read(trailer: &[u8], file_len: u64) -> Result<Self>
pub fn read(trailer: &[u8], file_len: u64) -> Result<Self>
Reads the trailer of a file of file_len bytes.
trailer is the Placement::TRAILER_LEN bytes at Placement::trailer_at.
§Errors
Error::Truncated if the file is too short or does not end with the magic,
Error::Reserved if a field that has to be zero is not, and Error::Truncated again if
the footer the trailer names does not fit between the header and the trailer.
Where the footer starts.
How long the footer is.
A usize because it is a u32 in the file and every target this builds for has a usize
at least that wide, so a host can read it in one call without a conversion that could fail.
Sourcepub const fn root_digest(&self) -> Digest
pub const fn root_digest(&self) -> Digest
The digest that covers the header and the footer.