Skip to main content

SealedBlobHeader

Struct SealedBlobHeader 

Source
pub struct SealedBlobHeader { /* private fields */ }
Expand description

What a sealed payload’s header says about its own layout: where its base nonce comes from, the chunk size it was sealed at, and the plaintext length it covers. Every other offset in the object is arithmetic over those, so a payload describes its own shape and nothing per-chunk is stored.

The header travels in the clear (a reader must know the chunk size before it can open anything) but is bound into every chunk’s AAD, so altering it makes the first chunk fail to open rather than silently re-framing the object.

Implementations§

Source§

impl SealedBlobHeader

Source

pub fn new( chunk_size: NonZeroU32, plaintext_len: u64, policy: &NoncePolicy, ) -> Self

Describe a payload of plaintext_len bytes sealed at chunk_size under policy. A random-stored policy draws its base nonce here, so the header is complete — and its Self::sealed_len known — before any chunk is sealed.

Source

pub fn parse(bytes: &[u8]) -> Result<Self, SealedBlobError>

Source

pub fn to_bytes(self) -> Vec<u8>

Source

pub fn prefix_len(self) -> u64

How many bytes the header occupies ahead of the first chunk: the fixed part, plus the base nonce when the payload stores one.

Source

pub fn chunk_size(self) -> NonZeroU32

Source

pub fn plaintext_len(self) -> u64

Source

pub fn chunk_count(self) -> u64

How many chunks the plaintext occupies. An empty blob still seals one tag-only chunk, so opening it authenticates its emptiness rather than trusting a zero-length object.

Source

pub fn sealed_chunk_len(self, index: u64) -> u64

The sealed length of chunk index: its plaintext plus one tag.

Source

pub fn sealed_len(self) -> u64

The whole sealed body: the header followed by every chunk. What a streaming upload declares as its length before a byte is sealed.

Source

pub fn covering_chunks( self, start: u64, end: u64, ) -> Result<Range<u64>, SealedBlobError>

The chunks covering plaintext start..end. A caller reads exactly these and no others; the range must lie inside the plaintext.

Source

pub fn sealed_span(self, chunks: Range<u64>) -> Range<u64>

Where chunks sit in the sealed object, as an offset span measured from the object’s first byte. The header is included in the offset, so this is what a ranged cloud read asks for verbatim.

Source

pub fn request_runs( self, chunks: Range<u64>, window: NonZeroU64, ) -> Vec<Range<u64>>

Split chunks into the runs one ranged read each should fetch: as many chunks as fit in window stored bytes, and never fewer than one (a chunk wider than the window still takes exactly one request). The window is how a reader trades round-trips against per-request size without changing what bytes it asks for — the union of the runs is always exactly chunks.

Source

pub fn plaintext_span(self, chunks: Range<u64>) -> Range<u64>

Where chunks sit in the plaintext.

Trait Implementations§

Source§

impl Clone for SealedBlobHeader

Source§

fn clone(&self) -> SealedBlobHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SealedBlobHeader

Source§

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

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

impl PartialEq for SealedBlobHeader

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SealedBlobHeader

Source§

impl Eq for SealedBlobHeader

Source§

impl StructuralPartialEq for SealedBlobHeader

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,