pub struct Secret<T>(/* private fields */)
where
T: Zeroize;
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: Zeroize + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Secret<T>where
T: Zeroize + Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Secret<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Secret<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Serialize for Secret<T>
impl<T> Serialize for Secret<T>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T> Eq for Secret<T>
impl<T> StructuralPartialEq for Secret<T>where
T: Zeroize,
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
)