Struct cargo_credential::secret::Secret
source · 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 to_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<'de, T> Deserialize<'de> for Secret<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Secret<T>where T: Deserialize<'de>,
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
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<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
impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,
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.