pub struct SecretBox<S: Zeroize> { /* private fields */ }
Expand description
Wrapper for the inner secret. Can be exposed by ExposeSecret
Implementations§
Source§impl<S: Zeroize + Default> SecretBox<S>
impl<S: Zeroize + Default> SecretBox<S>
Sourcepub fn new_with_mut(ctr: impl FnOnce(&mut S)) -> Self
pub fn new_with_mut(ctr: impl FnOnce(&mut S)) -> Self
Create a secret value using a function that can initialize the vale in-place.
Source§impl<S: Zeroize + Clone> SecretBox<S>
impl<S: Zeroize + Clone> SecretBox<S>
Sourcepub fn new_with_ctr(ctr: impl FnOnce() -> S) -> Self
pub fn new_with_ctr(ctr: impl FnOnce() -> S) -> Self
Create a secret value using the provided function as a constructor.
The implementation makes an effort to zeroize the locally constructed value before it is copied to the heap, and constructing it inside the closure minimizes the possibility of it being accidentally copied by other code.
Note: using Self::new
or Self::new_with_mut
is preferable when possible,
since this method’s safety relies on empyric evidence and may be violated on some targets.
Sourcepub fn try_new_with_ctr<E>(
ctr: impl FnOnce() -> Result<S, E>,
) -> Result<Self, E>
pub fn try_new_with_ctr<E>( ctr: impl FnOnce() -> Result<S, E>, ) -> Result<Self, E>
Same as Self::new_with_ctr
, but the constructor can be fallible.
Note: using Self::new
or Self::new_with_mut
is preferable when possible,
since this method’s safety relies on empyric evidence and may be violated on some targets.