Skip to main content

XChaCha20Codec

Struct XChaCha20Codec 

Source
pub struct XChaCha20Codec<C, K, N = OsNonce> { /* private fields */ }
Expand description

Authenticated XChaCha20-Poly1305 wrapper for any existing codec.

Implementations§

Source§

impl<C, K> XChaCha20Codec<C, K, OsNonce>

Source

pub fn new( inner: C, keys: K, context: impl Into<Vec<u8>>, max_plaintext_bytes: usize, ) -> Result<Self>

Uses OS randomness for nonces and binds ciphertext to context.

§Errors

Rejects an empty context or zero plaintext limit.

Source§

impl<C, K, N> XChaCha20Codec<C, K, N>

Source

pub fn with_nonce_source( inner: C, keys: K, context: impl Into<Vec<u8>>, max_plaintext_bytes: usize, nonce_source: N, ) -> Result<Self>

Injects a nonce source, primarily for deterministic testing.

§Errors

Rejects an empty context or zero plaintext limit.

Trait Implementations§

Source§

impl<T, C, K, N> Codec<T> for XChaCha20Codec<C, K, N>
where C: Codec<T>, K: EncryptionKeys, N: NonceSource,

Source§

fn encode(&self, value: &T) -> Result<Vec<u8>>

Encodes one value. Read more
Source§

fn decode(&self, bytes: &[u8]) -> Result<T>

Decodes one complete value. Read more

Auto Trait Implementations§

§

impl<C, K, N> Freeze for XChaCha20Codec<C, K, N>
where C: Freeze, K: Freeze, N: Freeze,

§

impl<C, K, N> RefUnwindSafe for XChaCha20Codec<C, K, N>

§

impl<C, K, N> Send for XChaCha20Codec<C, K, N>
where C: Send, K: Send, N: Send,

§

impl<C, K, N> Sync for XChaCha20Codec<C, K, N>
where C: Sync, K: Sync, N: Sync,

§

impl<C, K, N> Unpin for XChaCha20Codec<C, K, N>
where C: Unpin, K: Unpin, N: Unpin,

§

impl<C, K, N> UnsafeUnpin for XChaCha20Codec<C, K, N>

§

impl<C, K, N> UnwindSafe for XChaCha20Codec<C, K, N>
where C: UnwindSafe, K: UnwindSafe, N: UnwindSafe,

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