Skip to main content

PendingCiphertexts

Struct PendingCiphertexts 

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

Ciphertexts that failed with Error::UnknownKeyId, kept to be decrypted once the key is there.

A client MAY do this (RFC 9605 section 4.4.4): a new key can reach a receiver after the first frames encrypted with it. The store is bounded in frames and in bytes and drops the oldest entry to make room, so a peer naming keys that never come cannot grow it. Nothing held here is authenticated: it is only ever handed back for decryption. It has no clock; an application that wants entries to expire calls discard_oldest or clear on its own timer.

Implementations§

Source§

impl PendingCiphertexts

Source

pub fn new(max_frames: usize, max_bytes: usize) -> Self

A store of at most max_frames ciphertexts and max_bytes bytes (ciphertext plus metadata).

Source

pub fn len(&self) -> usize

The number of ciphertexts held.

Source

pub fn is_empty(&self) -> bool

Whether nothing is held.

Source

pub fn bytes(&self) -> usize

The bytes held: ciphertexts and their metadata.

Source

pub fn push( &mut self, metadata: &[u8], ciphertext: &[u8], ) -> Result<Option<u64>>

Keeps ciphertext and its metadata under the KID of its header, dropping the oldest entries if the bounds require it. Returns the KID, or None when the ciphertext alone exceeds the bounds and was not kept.

Fails when the header does not parse: such a ciphertext can never be decrypted.

Source

pub fn take(&mut self, kid: u64) -> Vec<PendingCiphertext>

Removes and returns the ciphertexts waiting for kid, oldest first: call it when the key for kid has been added, and decrypt each.

Source

pub fn discard_oldest(&mut self, count: usize)

Drops the count oldest ciphertexts.

Source

pub fn clear(&mut self)

Drops everything.

Trait Implementations§

Source§

impl Debug for PendingCiphertexts

Source§

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

Formats the value using the given formatter. Read more

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> 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> Same for T

Source§

type Output = T

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