pub trait ExposeSecret<'max, T, MEC: Unsigned, EC: Unsigned>: Sized {
type Exposed<'brand>
where 'max: 'brand;
type Next: ExposeSecret<'max, T, MEC, Sum<EC, U1>>
where EC: Add<U1> + Unsigned + IsLessOrEqual<MEC, Output = True>,
Sum<EC, U1>: Unsigned + IsLessOrEqual<MEC, Output = True> + Add<U1>;
// Required method
fn expose_secret<ReturnType, ClosureType>(
self,
scope: ClosureType,
) -> (Self::Next, ReturnType)
where for<'brand> ClosureType: FnOnce(Self::Exposed<'brand>) -> ReturnType,
EC: Add<U1> + IsLessOrEqual<MEC, Output = True>,
Sum<EC, U1>: Unsigned + Add<U1> + IsLessOrEqual<MEC, Output = True>;
}Expand description
A trait for safely exposing secrets with a limited exposure count.
The ExposeSecret trait provides a mechanism to progressively expose a secret
value in a controlled manner, with an invariant lifetime and compile-time guarantees.
It allows for limiting the exposure of a secret to a maximum count (MEC).
The exposure count (EC) is tracked at compile time to ensure that it does not exceed the specified maximum count.
§Type Parameters
'max: A lifetime parameter indicating the lifetime of the value of the type that implements this trait.T: The type of the secret being exposed.MEC: A type-level unsigned integer (withtypenum::Unsignedtrait bound) representing the maximum exposure count.EC: A type-level unsigned integer (withtypenum::Unsignedtrait bound) representing the current exposure count.
Required Associated Types§
Sourcetype Exposed<'brand>
where
'max: 'brand
type Exposed<'brand> where 'max: 'brand
A wrapper type representing the exposed secret. It is associated with a lifetime 'brand, indicating the lifetime of the wrapper type, which is strictly a subtype of 'max,
Sourcetype Next: ExposeSecret<'max, T, MEC, Sum<EC, U1>>
where
EC: Add<U1> + Unsigned + IsLessOrEqual<MEC, Output = True>,
Sum<EC, U1>: Unsigned + IsLessOrEqual<MEC, Output = True> + Add<U1>
type Next: ExposeSecret<'max, T, MEC, Sum<EC, U1>> where EC: Add<U1> + Unsigned + IsLessOrEqual<MEC, Output = True>, Sum<EC, U1>: Unsigned + IsLessOrEqual<MEC, Output = True> + Add<U1>
The Secret<T, _, _> with an incremented count (i.e. EC) after exposing the secret.
It is a new value of a type which implements the same trait, namely, ExposeSecret with an incremented exposure count, i.e. the new EC = previous EC + 1.
Required Methods§
Sourcefn expose_secret<ReturnType, ClosureType>(
self,
scope: ClosureType,
) -> (Self::Next, ReturnType)
fn expose_secret<ReturnType, ClosureType>( self, scope: ClosureType, ) -> (Self::Next, ReturnType)
Exposes the secret and returns the Secret<T, _, _> with an incremented count (i.e. EC), along with the result of a provided closure.
It is impossible to return Self::Exposed associated type out from the closure scope.
§Parameters
self.scope: A closure (of the type given by the type parameterClosureType) that takes the exposed secret, of typeExposed<'brand>and returns a result, of typeReturnType.
Returns (Self::Next, ReturnType)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.