pub struct Secret<T: Zeroize>(/* private fields */);
Expand description
Wrapper type for secret values such as passwords or authentication keys.
Once wrapped, the inner value cannot leak accidentally, as both the std::fmt::Display
and Debug
implementations cover up the actual value and only show the type.
If you need access to the inner value, there is an expose method.
To make sure nothing leaks after the Secret
has been dropped, a custom Drop
implementation will zero-out the underlying memory.
Implementations§
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Secret<T>where
T: Deserialize<'de> + Zeroize,
impl<'de, T> Deserialize<'de> for Secret<T>where
T: Deserialize<'de> + Zeroize,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq + Zeroize> Eq for Secret<T>
impl<T: Zeroize> StructuralPartialEq for Secret<T>
Auto Trait Implementations§
impl<T> Freeze for Secret<T>where
T: Freeze,
impl<T> RefUnwindSafe for Secret<T>where
T: RefUnwindSafe,
impl<T> Send for Secret<T>where
T: Send,
impl<T> Sync for Secret<T>where
T: Sync,
impl<T> Unpin for Secret<T>where
T: Unpin,
impl<T> UnwindSafe for Secret<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)