#[repr(align(4096))]pub struct Secured<T: Copy>(/* private fields */);
Expand description
A stack-allocated value protected by locking its virtual memory page in physical memory.
Implementations§
Source§impl<T: Copy> Secured<T>
impl<T: Copy> Secured<T>
Sourcepub fn borrow_default<F, R>(&mut self, f: F) -> R
pub fn borrow_default<F, R>(&mut self, f: F) -> R
For an existing Secured
instance, fill with the default value
of T
and call the closure f
with a mutable reference.
Sourcepub fn borrow_random<F, R>(&mut self, rng: impl RngCore, f: F) -> R
pub fn borrow_random<F, R>(&mut self, rng: impl RngCore, f: F) -> R
For an existing Secured
instance, fill with a set of random
bytes, then return the result of calling the closure f
with
a mutable reference.
Sourcepub fn borrow_take<F, R>(&mut self, take: &mut T, f: F) -> R
pub fn borrow_take<F, R>(&mut self, take: &mut T, f: F) -> R
For an existing Secured
instance, fill with the default value
of T
and call the closure f
with a mutable reference.
Sourcepub fn borrow_uninit<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(SecureRef<&mut MaybeUninit<T>>) -> R,
pub fn borrow_uninit<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(SecureRef<&mut MaybeUninit<T>>) -> R,
For an existing Secured
instance, call a closure f
with a
mutable reference to an uninitialized T
.
Sourcepub fn default<F, R>(f: F) -> R
pub fn default<F, R>(f: F) -> R
Fill a Secured
with the default value of T
and return the result
of calling the closure f
with a mutable reference.
Sourcepub fn random<F, R>(rng: impl RngCore, f: F) -> R
pub fn random<F, R>(rng: impl RngCore, f: F) -> R
Fill a Secured
with a set of random bytes, then return the
result of calling the closure f
with a mutable reference.
Sourcepub fn take<F, R>(take: &mut T, f: F) -> R
pub fn take<F, R>(take: &mut T, f: F) -> R
Fill a Secured
by coping an existing value of type T
,
and zeroize the original copy. Return the result of calling the
closure f
with a mutable reference.
Sourcepub fn uninit<F, R>(f: F) -> Rwhere
F: FnOnce(SecureRef<&mut MaybeUninit<T>>) -> R,
pub fn uninit<F, R>(f: F) -> Rwhere
F: FnOnce(SecureRef<&mut MaybeUninit<T>>) -> R,
Call the closure f
with a mutable reference to an uninitialized
T
.