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
impl SealedBlobHeader
Sourcepub fn new(
chunk_size: NonZeroU32,
plaintext_len: u64,
policy: &NoncePolicy,
) -> Self
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.
pub fn parse(bytes: &[u8]) -> Result<Self, SealedBlobError>
pub fn to_bytes(self) -> Vec<u8> ⓘ
Sourcepub fn prefix_len(self) -> u64
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.
pub fn chunk_size(self) -> NonZeroU32
pub fn plaintext_len(self) -> u64
Sourcepub fn chunk_count(self) -> u64
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.
Sourcepub fn sealed_chunk_len(self, index: u64) -> u64
pub fn sealed_chunk_len(self, index: u64) -> u64
The sealed length of chunk index: its plaintext plus one tag.
Sourcepub fn sealed_len(self) -> u64
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.
Sourcepub fn covering_chunks(
self,
start: u64,
end: u64,
) -> Result<Range<u64>, SealedBlobError>
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.
Sourcepub fn sealed_span(self, chunks: Range<u64>) -> Range<u64>
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.
Sourcepub fn request_runs(
self,
chunks: Range<u64>,
window: NonZeroU64,
) -> Vec<Range<u64>>
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.
Trait Implementations§
Source§impl Clone for SealedBlobHeader
impl Clone for SealedBlobHeader
Source§fn clone(&self) -> SealedBlobHeader
fn clone(&self) -> SealedBlobHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SealedBlobHeader
impl Debug for SealedBlobHeader
Source§impl PartialEq for SealedBlobHeader
impl PartialEq for SealedBlobHeader
impl Copy for SealedBlobHeader
impl Eq for SealedBlobHeader
impl StructuralPartialEq for SealedBlobHeader
Auto Trait Implementations§
impl Freeze for SealedBlobHeader
impl RefUnwindSafe for SealedBlobHeader
impl Send for SealedBlobHeader
impl Sync for SealedBlobHeader
impl Unpin for SealedBlobHeader
impl UnsafeUnpin for SealedBlobHeader
impl UnwindSafe for SealedBlobHeader
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.