pub struct Header {
pub major: u16,
pub minor: u16,
pub flags: u16,
pub header_size: u16,
pub content_hash: [u8; 32],
pub dialect_hash: u64,
pub total_size: u64,
pub sections: [SectionSpan; 17],
}Expand description
Parsed fixed header.
Fields§
§major: u16§minor: u16§flags: u16§header_size: u16§content_hash: [u8; 32]§dialect_hash: u64§total_size: u64§sections: [SectionSpan; 17]Implementations§
Source§impl Header
impl Header
pub fn span(&self, section: Section) -> SectionSpan
pub fn span_mut(&mut self, section: Section) -> &mut SectionSpan
Sourcepub fn parse(buf: &[u8]) -> Result<Header>
pub fn parse(buf: &[u8]) -> Result<Header>
Parse and structurally check the fixed header.
This checks the prefix, versions and flags only. Section ranges are
validated by crate::validate::validate, which owns the full invariants.
Sourcepub fn try_write(&self, out: &mut [u8]) -> Result<()>
pub fn try_write(&self, out: &mut [u8]) -> Result<()>
Serialize this header, returning an error when out is too short.
Prefer this over Header::write in code that accepts a caller-owned
buffer: the failure is a value, not a panic.
Sourcepub fn write(&self, out: &mut [u8])
pub fn write(&self, out: &mut [u8])
Serialize this header into the first HEADER_SIZE bytes of out.
§Panics
Panics when out is shorter than HEADER_SIZE. Use
Header::try_write for a fallible form.
Trait Implementations§
impl Copy for Header
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.