Trait RTExposeSecret

Source
pub trait RTExposeSecret<'secret, T> {
    type Error: Display + Debug;
    type Exposed<'brand>
       where 'secret: 'brand;

    // Required methods
    fn expose_secret<ReturnType, ClosureType>(
        &self,
        scope: ClosureType,
    ) -> ReturnType
       where for<'brand> ClosureType: FnOnce(Self::Exposed<'brand>) -> ReturnType;
    fn try_expose_secret<ReturnType, ClosureType>(
        &self,
        scope: ClosureType,
    ) -> Result<ReturnType, Self::Error>
       where for<'brand> ClosureType: FnOnce(Self::Exposed<'brand>) -> ReturnType;
}
Expand description

A trait for exposing secrets with runtime checking.

Required Associated Types§

Source

type Error: Display + Debug

The type representing the Error variant as part of the Result returned type in try_expose_secret.

Source

type Exposed<'brand> where 'secret: 'brand

The type representing the exposed secret.

Required Methods§

Source

fn expose_secret<ReturnType, ClosureType>( &self, scope: ClosureType, ) -> ReturnType
where for<'brand> ClosureType: FnOnce(Self::Exposed<'brand>) -> ReturnType,

Exposes the secret with runtime checking.

§Parameters
  • scope: A closure that takes the exposed secret and returns a value of the ReturnType.
§Returns

The value returned by the closure.

Source

fn try_expose_secret<ReturnType, ClosureType>( &self, scope: ClosureType, ) -> Result<ReturnType, Self::Error>
where for<'brand> ClosureType: FnOnce(Self::Exposed<'brand>) -> ReturnType,

Tries to expose the secret with runtime checking.

§Parameters
  • scope: A closure that takes the exposed secret and returns a value of the ReturnType.
§Returns
  • Ok: The value returned by the closure.
  • Err: If there is an error during exposure, it returns an error of type Self::Error.

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.

Implementors§

Source§

impl<'secret, T: Zeroize> RTExposeSecret<'secret, &'secret T> for SecrecySecret<T>

Source§

type Error = Infallible

Source§

type Exposed<'brand> = RTExposedSecret<'brand, &'brand T> where 'secret: 'brand

Source§

impl<'secret, T: Zeroize, MEC: ChooseMinimallyRepresentableUInt + Unsigned + IsGreater<U0, Output = True> + Debug> RTExposeSecret<'secret, &'secret T> for RTSecret<T, MEC>

Source§

type Error = ExposeSecretError<MEC>

Source§

type Exposed<'brand> = RTExposedSecret<'brand, &'brand T> where 'secret: 'brand