Skip to main content

Header

Struct Header 

Source
#[non_exhaustive]
pub struct Header { pub codec: CodecId, pub crypto: CryptoId, pub orig_len: u64, pub nonce: Option<[u8; 12]>, pub tag: Option<[u8; 16]>, pub payload_offset: usize, pub aad_len: usize, }
Expand description

The decoded header of one on-binary entry, as returned by read_header.

#[non_exhaustive]: the on-binary layout is expected to grow (a content hash, per-entry flags), so fields get added over time. Read the fields you need; do not build one by hand or match it exhaustively.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§codec: CodecId

The compression applied to the payload.

§crypto: CryptoId

The AEAD cipher the payload was sealed with, if any.

§orig_len: u64

Length of the file before compression and encryption, in bytes.

Decoders use it to size the output buffer, so it comes from untrusted bytes and must be treated as a claim rather than a fact: reserve fallibly, and check the decoded length against it.

§nonce: Option<[u8; 12]>

The AEAD nonce, present exactly when crypto is not CryptoId::None. Stored in the clear, and unique per entry.

§tag: Option<[u8; 16]>

The detached AEAD authentication tag, present under the same condition as nonce.

§payload_offset: usize

Offset into the entry at which the payload begins, that is the length of the header this Header was parsed from.

§aad_len: usize

Length of the leading bytes – the tag byte and the length varint – that a sealed entry’s AEAD tag covers as associated data, so that the codec, cipher and claimed length cannot be rewritten under a tag that still verifies. entry[..aad_len] is what to hand the cipher.

Trait Implementations§

Source§

impl Clone for Header

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 Copy for Header

Source§

impl Debug for Header

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Header

Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Header

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.