Struct Secret

Source
pub struct Secret<T: ?Sized>(/* private fields */);
Expand description

Implementations§

Source§

impl<T> Secret<T>

Source

pub const fn new(secret: T) -> Self

Source

pub fn from(secret: impl Into<T>) -> Self

Source

pub fn try_from<U: TryInto<T>>(secret: U) -> Result<Self, Secret<U::Error>>

Source

pub const fn expose_secret(&self) -> &T

Trait Implementations§

Source§

impl<T, U> Add<Secret<U>> for Secret<T>
where T: Add<U>,

Source§

type Output = Secret<<T as Add<U>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Secret<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T, U> AddAssign<Secret<U>> for Secret<T>
where T: AddAssign<U>,

Source§

fn add_assign(&mut self, rhs: Secret<U>)

Performs the += operation. Read more
Source§

impl<T, U> BitAnd<Secret<U>> for Secret<T>
where T: BitAnd<U>,

Source§

type Output = Secret<<T as BitAnd<U>>::Output>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Secret<U>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, U> BitAndAssign<Secret<U>> for Secret<T>
where T: BitAndAssign<U>,

Source§

fn bitand_assign(&mut self, rhs: Secret<U>)

Performs the &= operation. Read more
Source§

impl<T, U> BitOr<Secret<U>> for Secret<T>
where T: BitOr<U>,

Source§

type Output = Secret<<T as BitOr<U>>::Output>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Secret<U>) -> Self::Output

Performs the | operation. Read more
Source§

impl<T, U> BitOrAssign<Secret<U>> for Secret<T>
where T: BitOrAssign<U>,

Source§

fn bitor_assign(&mut self, rhs: Secret<U>)

Performs the |= operation. Read more
Source§

impl<T, U> BitXor<Secret<U>> for Secret<T>
where T: BitXor<U>,

Source§

type Output = Secret<<T as BitXor<U>>::Output>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Secret<U>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, U> BitXorAssign<Secret<U>> for Secret<T>
where T: BitXorAssign<U>,

Source§

fn bitxor_assign(&mut self, rhs: Secret<U>)

Performs the ^= operation. Read more
Source§

impl<T: Clone + ?Sized> Clone for Secret<T>

Source§

fn clone(&self) -> Secret<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Secret<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default + ?Sized> Default for Secret<T>

Source§

fn default() -> Secret<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T: Deserialize<'de>> Deserialize<'de> for Secret<T>

Available on crate feature serde only.

This API requires the following crate features to be activated: serde

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<E: Error> Display for Secret<E>

Available on crate feature std only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> Div<Secret<U>> for Secret<T>
where T: Div<U>,

Source§

type Output = Secret<<T as Div<U>>::Output>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Secret<U>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T, U> DivAssign<Secret<U>> for Secret<T>
where T: DivAssign<U>,

Source§

fn div_assign(&mut self, rhs: Secret<U>)

Performs the /= operation. Read more
Source§

impl<T: Dummy<U>, U> Dummy<U> for Secret<T>

Available on crate feature fake only.
Source§

fn dummy_with_rng<R: Rng + ?Sized>(config: &U, rng: &mut R) -> Self

Generate a dummy value for a given type using a random number generator.
Source§

fn dummy(config: &U) -> Self

Generate a dummy value for a type. Read more
Source§

impl<E: Error> Error for Secret<E>

Available on crate feature std only.
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<T> From<Option<Secret<T>>> for Secret<Option<T>>

Source§

fn from(secret: Option<Secret<T>>) -> Self

Converts to this type from the input type.
Source§

impl<T, E> From<Result<Secret<T>, E>> for Secret<Result<T, E>>

Source§

fn from(secret: Result<Secret<T>, E>) -> Self

Converts to this type from the input type.
Source§

impl<T, E> From<Result<Secret<T>, Secret<E>>> for Secret<Result<T, E>>

Source§

fn from(secret: Result<Secret<T>, Secret<E>>) -> Self

Converts to this type from the input type.
Source§

impl<T, E> From<Result<T, Secret<E>>> for Secret<Result<T, E>>

Source§

fn from(secret: Result<T, Secret<E>>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for Secret<T>

Source§

fn from(secret: T) -> Self

Converts to this type from the input type.
Source§

impl<S: FromIterator<T>, T> FromIterator<Secret<T>> for Secret<S>

Source§

fn from_iter<I: IntoIterator<Item = Secret<T>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: FromStr> FromStr for Secret<T>

Source§

type Err = Secret<<T as FromStr>::Err>

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T: Hash + ?Sized> Hash for Secret<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, U> Mul<Secret<U>> for Secret<T>
where T: Mul<U>,

Source§

type Output = Secret<<T as Mul<U>>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Secret<U>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, U> MulAssign<Secret<U>> for Secret<T>
where T: MulAssign<U>,

Source§

fn mul_assign(&mut self, rhs: Secret<U>)

Performs the *= operation. Read more
Source§

impl<T> Neg for Secret<T>
where T: Neg,

Source§

type Output = Secret<<T as Neg>::Output>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> Not for Secret<T>
where T: Not,

Source§

type Output = Secret<<T as Not>::Output>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<T: Ord + ?Sized> Ord for Secret<T>

Source§

fn cmp(&self, other: &Secret<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq + ?Sized> PartialEq for Secret<T>

Source§

fn eq(&self, other: &Secret<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd + ?Sized> PartialOrd for Secret<T>

Source§

fn partial_cmp(&self, other: &Secret<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, U> Rem<Secret<U>> for Secret<T>
where T: Rem<U>,

Source§

type Output = Secret<<T as Rem<U>>::Output>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Secret<U>) -> Self::Output

Performs the % operation. Read more
Source§

impl<T, U> RemAssign<Secret<U>> for Secret<T>
where T: RemAssign<U>,

Source§

fn rem_assign(&mut self, rhs: Secret<U>)

Performs the %= operation. Read more
Source§

impl<T: Serialize> SerializableSecret<T> for &Secret<T>

Available on crate feature serde only.
Source§

type Exposed<'a> = &'a T where T: 'a, Self: 'a

Source§

fn expose_via(&self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'_>

To reduce the number of functions that are able to expose secrets we require that the Secret::expose_secret function is passed in here.
Source§

impl<T: Serialize> SerializableSecret<T> for Secret<T>

Available on crate feature serde only.
Source§

type Exposed<'a> = &'a T where T: 'a

Source§

fn expose_via(&self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'_>

To reduce the number of functions that are able to expose secrets we require that the Secret::expose_secret function is passed in here.
Source§

impl<T, U> Shl<Secret<U>> for Secret<T>
where T: Shl<U>,

Source§

type Output = Secret<<T as Shl<U>>::Output>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: Secret<U>) -> Self::Output

Performs the << operation. Read more
Source§

impl<T, U> ShlAssign<Secret<U>> for Secret<T>
where T: ShlAssign<U>,

Source§

fn shl_assign(&mut self, rhs: Secret<U>)

Performs the <<= operation. Read more
Source§

impl<T, U> Shr<Secret<U>> for Secret<T>
where T: Shr<U>,

Source§

type Output = Secret<<T as Shr<U>>::Output>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: Secret<U>) -> Self::Output

Performs the >> operation. Read more
Source§

impl<T, U> ShrAssign<Secret<U>> for Secret<T>
where T: ShrAssign<U>,

Source§

fn shr_assign(&mut self, rhs: Secret<U>)

Performs the >>= operation. Read more
Source§

impl<T, U> Sub<Secret<U>> for Secret<T>
where T: Sub<U>,

Source§

type Output = Secret<<T as Sub<U>>::Output>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Secret<U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, U> SubAssign<Secret<U>> for Secret<T>
where T: SubAssign<U>,

Source§

fn sub_assign(&mut self, rhs: Secret<U>)

Performs the -= operation. Read more
Source§

impl<T: TryZeroize> TryZeroize for Secret<T>

Available on crate feature zeroize only.
Source§

fn try_zeroize(&mut self) -> bool

Try to zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<T: Zeroize + ?Sized> Zeroize for Secret<T>

Available on crate feature zeroize only.
Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<T: Copy + ?Sized> Copy for Secret<T>

Source§

impl<T: Eq + ?Sized> Eq for Secret<T>

Source§

impl<T: ?Sized> StructuralPartialEq for Secret<T>

Source§

impl<T: ZeroizeOnDrop> ZeroizeOnDrop for Secret<T>

Available on crate feature zeroize only.

Auto Trait Implementations§

§

impl<T> Freeze for Secret<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for Secret<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for Secret<T>
where T: Send + ?Sized,

§

impl<T> Sync for Secret<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for Secret<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for Secret<T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: Rng + ?Sized, Self: FakeBase<U>,

Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,