pub type SecretSlice<S> = SecretBox<[S]>;
Expand description
Secret slice type.
This is a type alias for [SecretBox<[S]>
] which supports some helpful trait impls.
Notably it has a From<Vec<S>>
impl which is the preferred method for construction.
Aliased Type§
struct SecretSlice<S> { /* private fields */ }
Implementations
Source§impl<S: Zeroize + Clone> SecretBox<S>
impl<S: Zeroize + Clone> SecretBox<S>
Sourcepub fn init_with(ctr: impl FnOnce() -> S) -> Self
pub fn init_with(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::init_with_mut
is preferable when possible,
since this method’s safety relies on empiric evidence and may be violated on some targets.
Sourcepub fn try_init_with<E>(ctr: impl FnOnce() -> Result<S, E>) -> Result<Self, E>
pub fn try_init_with<E>(ctr: impl FnOnce() -> Result<S, E>) -> Result<Self, E>
Same as Self::init_with
, but the constructor can be fallible.
Note: using Self::new
or Self::init_with_mut
is preferable when possible,
since this method’s safety relies on empyric evidence and may be violated on some targets.