pub enum Codec {
Aead(Box<Aead>),
Null,
}Expand description
The codec actually installed: real AEAD, or a pass-through used only on a
localhost dev stack where no key is configured. Production refuses to boot
without a real key, so Codec::Null never runs there.
Variants§
Aead(Box<Aead>)
Boxed: ring’s expanded AES key schedule makes Aead ~544 bytes, and an
enum sized to its largest variant would be paid for by every Null too.
Null
Implementations§
Source§impl Codec
impl Codec
Sourcepub fn new(raw_key: Option<&str>) -> Result<Self>
pub fn new(raw_key: Option<&str>) -> Result<Self>
Build the codec for a configured key, or the pass-through when none is set. Production validates that a key IS set before calling this.
pub fn encrypt(&self, plaintext: &str) -> String
Sourcepub fn encrypt_bound(&self, plaintext: &str, aad: &[u8]) -> String
pub fn encrypt_bound(&self, plaintext: &str, aad: &[u8]) -> String
Encrypt bound to aad — see Aead::encrypt_bound.
Codec::Null passes through, so a dev stack with no key configured gets
no binding either. That is the same trade the unbound path already makes,
and production is required to configure a key.
Sourcepub fn decrypt_bound(&self, token: &str, aad: &[u8]) -> Result<String>
pub fn decrypt_bound(&self, token: &str, aad: &[u8]) -> Result<String>
Decrypt a bound record — see Aead::decrypt_bound.
pub fn maybe_decrypt(&self, value: &str) -> Result<String>
Auto Trait Implementations§
impl Freeze for Codec
impl RefUnwindSafe for Codec
impl Send for Codec
impl Sync for Codec
impl Unpin for Codec
impl UnsafeUnpin for Codec
impl UnwindSafe for Codec
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more