pub struct Zeroizing<T: Zeroize>(/* private fields */);Expand description
A wrapper that clears its initialized value when dropped.
Implementations§
Source§impl<T: Zeroize> Zeroizing<T>
impl<T: Zeroize> Zeroizing<T>
pub const fn new(value: T) -> Self
Sourcepub fn into_inner(self) -> Twhere
T: Default,
pub fn into_inner(self) -> Twhere
T: Default,
Move the protected value out, leaving a zero/default value for Drop.
This is primarily useful at an ownership boundary where an exact-size boxed secret must become the caller’s output without creating a second secret allocation.
Source§impl<const N: usize> Zeroizing<[u8; N]>
impl<const N: usize> Zeroizing<[u8; N]>
Sourcepub fn into_inner_array(self) -> [u8; N]
pub fn into_inner_array(self) -> [u8; N]
Move a protected byte array out while leaving an all-zero replacement.
This is the fixed-array counterpart to Self::into_inner for array
lengths whose standard-library Default implementation is unavailable
on the supported compiler baseline.
Trait Implementations§
impl<T: Eq + Zeroize> Eq for Zeroizing<T>
Source§impl<T: Ord + Zeroize> Ord for Zeroizing<T>
impl<T: Ord + Zeroize> Ord for Zeroizing<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd + Zeroize> PartialOrd for Zeroizing<T>
impl<T: PartialOrd + Zeroize> PartialOrd for Zeroizing<T>
impl<T: PartialEq + Zeroize> StructuralPartialEq for Zeroizing<T>
impl<T: Zeroize> ZeroizeOnDrop for Zeroizing<T>
Auto Trait Implementations§
impl<T> Freeze for Zeroizing<T>where
T: Freeze,
impl<T> RefUnwindSafe for Zeroizing<T>where
T: RefUnwindSafe,
impl<T> Send for Zeroizing<T>where
T: Send,
impl<T> Sync for Zeroizing<T>where
T: Sync,
impl<T> Unpin for Zeroizing<T>where
T: Unpin,
impl<T> UnsafeUnpin for Zeroizing<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Zeroizing<T>where
T: 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