Skip to main content

ExposeSensitive

Trait ExposeSensitive 

Source
pub trait ExposeSensitive {
    type Exposed;

    // Required methods
    fn expose(&self) -> &Self::Exposed;
    fn expose_owned(self) -> Self::Exposed;
}
Expand description

A trait for types that can expose their inner secret value. This is implemented for Sensitive<T> and can be implemented for other wrapper types as needed. The expose and expose_owned methods are intentionally explicit and require justification in comments to prevent accidental misuse.

Required Associated Types§

Source

type Exposed

The type of the inner value that is being wrapped. This is used to define the return type of the expose and expose_owned methods.

Required Methods§

Source

fn expose(&self) -> &Self::Exposed

Explicitly borrow the secret value. This exposes the secret to logging. This should be used exactly only when interacting with APIs we do not control. Each usage of expose MUST have a comment justifying why it is necessary and acknowledging that the appropriate checks have been performed.

Source

fn expose_owned(self) -> Self::Exposed

Consume the wrapper and return the inner value. This exposes the secret to logging. This should be used exactly only when interacting with APIs we do not control. Each usage of expose MUST have a comment justifying why it is necessary and acknowledging that the appropriate checks have been performed.

Implementors§