pub trait ProtectedInit:
ExposeProtected
+ From<SecureBox<Self::Target>>
+ Sized {
// Provided methods
fn init<F>(f: F) -> Self
where F: FnOnce(SecureRef<&mut Self::Target>),
Self::Target: Copy + FillBytes { ... }
fn init_default<F>(f: F) -> Self
where F: FnOnce(SecureRef<&mut Self::Target>),
Self::Target: Default { ... }
fn init_random<F>(rng: impl RngCore, f: F) -> Self
where F: FnOnce(SecureRef<&mut Self::Target>),
Self::Target: Copy + FillBytes { ... }
fn init_take<F>(from: &mut Self::Target, f: F) -> Self
where F: FnOnce(SecureRef<&mut Self::Target>),
Self::Target: DefaultIsZeroes { ... }
fn init_with<F>(f: F) -> Self
where F: FnOnce() -> Self::Target,
Self::Target: Sized { ... }
fn try_init_with<F, E>(f: F) -> Result<Self, E>
where F: FnOnce() -> Result<Self::Target, E>,
Self::Target: Sized { ... }
fn random(rng: impl RngCore) -> Self
where Self::Target: Copy + FillBytes { ... }
fn take(from: &mut Self::Target) -> Self
where Self::Target: DefaultIsZeroes { ... }
}Expand description
Initialize a protected container type for a sized value.
Provided Methods§
Sourcefn init<F>(f: F) -> Self
fn init<F>(f: F) -> Self
For a concrete type implementing FillBytes, initialize with the
standard indicator value and call the closure f with a mutable
reference to the contained value before applying protections.
Sourcefn init_default<F>(f: F) -> Self
fn init_default<F>(f: F) -> Self
Initialize with the default value for Self::Target, and call the
closure f with a mutable reference to the contained value before
applying protections.
Sourcefn init_random<F>(rng: impl RngCore, f: F) -> Self
fn init_random<F>(rng: impl RngCore, f: F) -> Self
Initialize with a randomized value for Self::Target, and call the
closure f with a mutable reference to the contained value before
applying protections.
Sourcefn init_take<F>(from: &mut Self::Target, f: F) -> Self
fn init_take<F>(from: &mut Self::Target, f: F) -> Self
Initialize by copying the value contained in from and zeroizing the
existing copy. Call the closure f with a mutable reference to the
contained value before applying protections.
Sourcefn init_with<F>(f: F) -> Self
fn init_with<F>(f: F) -> Self
Initialize by calling the closure f, store the resulting
instance of Self::Target and apply protections.
Sourcefn try_init_with<F, E>(f: F) -> Result<Self, E>
fn try_init_with<F, E>(f: F) -> Result<Self, E>
Initialize by calling the fallible closure f, store the resulting
instance of Self::Target and apply protections. On failure, return
the error type E.
Sourcefn random(rng: impl RngCore) -> Self
fn random(rng: impl RngCore) -> Self
Create a new protected instance containing a random value.
Sourcefn take(from: &mut Self::Target) -> Selfwhere
Self::Target: DefaultIsZeroes,
fn take(from: &mut Self::Target) -> Selfwhere
Self::Target: DefaultIsZeroes,
Create a new protected instance by copying and zeroizing an existing value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".