pub struct Secret<T> {
inner: T,
}
Expand description
A wrapper for values that should not be printed.
This type does not implement Display
, and has a Debug
impl that hides
the contained value.
let token = Secret::from("super secret string");
assert_eq!(format!("{:?}", token), "Secret { inner: \"REDACTED\" }");
Currently, we write a borrowed Secret<T>
as Secret<&T>
.
The as_deref
and owned
methods can
be used to convert back and forth between Secret<String>
and Secret<&str>
.
Fields§
§inner: T
Implementations§
source§impl<T> Secret<T>
impl<T> Secret<T>
sourcepub fn expose(self) -> T
pub fn expose(self) -> T
Unwraps the contained value.
Use of this method marks the boundary of where the contained value is hidden.
Trait Implementations§
source§impl<T: PartialEq> PartialEq<Secret<T>> for Secret<T>
impl<T: PartialEq> PartialEq<Secret<T>> for Secret<T>
impl<T: Eq> Eq for Secret<T>
impl<T> StructuralEq for Secret<T>
impl<T> StructuralPartialEq for Secret<T>
Auto Trait Implementations§
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> FromFd for Twhere
T: From<OwnedFd>,
impl<T> FromFd for Twhere T: From<OwnedFd>,
§impl<T> FromFilelike for Twhere
T: From<OwnedFd>,
impl<T> FromFilelike for Twhere T: From<OwnedFd>,
§fn from_filelike(owned: OwnedFd) -> T
fn from_filelike(owned: OwnedFd) -> T
Constructs a new instance of
Self
from the given filelike object. Read more§fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
fn from_into_filelike<Owned>(owned: Owned) -> Twhere Owned: IntoFilelike,
Constructs a new instance of
Self
from the given filelike object
converted from into_owned
. Read more§impl<T> FromSocketlike for Twhere
T: From<OwnedFd>,
impl<T> FromSocketlike for Twhere T: From<OwnedFd>,
§fn from_socketlike(owned: OwnedFd) -> T
fn from_socketlike(owned: OwnedFd) -> T
Constructs a new instance of
Self
from the given socketlike object.§fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
fn from_into_socketlike<Owned>(owned: Owned) -> Twhere Owned: IntoSocketlike,
Constructs a new instance of
Self
from the given socketlike object
converted from into_owned
.Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.