Struct cargo::util::auth::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 owned methods can be used to convert back and forth between Secret<String> and Secret<&str>.

Fields§

§inner: T

Implementations§

Unwraps the contained value.

Use of this method marks the boundary of where the contained value is hidden.

Converts a Secret<T> to a Secret<&T::Target>.

let owned: Secret<String> = Secret::from(String::from("token"));
let borrowed: Secret<&str> = owned.as_deref();

Converts a Secret<T> to a Secret<&T>.

Converts a Secret<T> to a Secret<U> by applying f to the contained value.

Converts a Secret containing a borrowed type to a Secret containing the corresponding owned type.

let borrowed: Secret<&str> = Secret::from("token");
let owned: Secret<String> = borrowed.owned();

Converts a Secret<Result<T, E>> to a Result<Secret<T>, E>.

Checks if the contained value is empty.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.
Converts to this type from the input type.

Returns the argument unchanged.

👎Deprecated since 1.0.0: FromFd::from_fd is replaced by From<OwnedFd>::from
Constructs a new instance of Self from the given file descriptor. Read more
Constructs a new instance of Self from the given file descriptor converted from into_owned. Read more
Constructs a new instance of Self from the given filelike object. Read more
Constructs a new instance of Self from the given filelike object converted from into_owned. Read more
Constructs a new instance of Self from the given socketlike object.
Constructs a new instance of Self from the given socketlike object converted from into_owned.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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.