pub struct FnCodex<F> { /* private fields */ }Expand description
Wrap a user-provided closure as a Codex.
The closure is presumed to be an involution; nothing in the type system
enforces this and violating the property will corrupt every stored key.
Test your closure with the property test in the codex integration suite
before using it in production.
§Examples
use key_vault::codex::{Codex, FnCodex};
// XOR with a fixed mask is an involution.
let codex = FnCodex::new(|b: u8| b ^ 0x5a);
assert_eq!(codex.decode(codex.encode(0x42)), 0x42);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for FnCodex<F>where
F: Freeze,
impl<F> RefUnwindSafe for FnCodex<F>where
F: RefUnwindSafe,
impl<F> Send for FnCodex<F>where
F: Send,
impl<F> Sync for FnCodex<F>where
F: Sync,
impl<F> Unpin for FnCodex<F>where
F: Unpin,
impl<F> UnsafeUnpin for FnCodex<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for FnCodex<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more