SecretMicrotype

Trait SecretMicrotype 

Source
pub trait SecretMicrotype: ExposeSecret<Self::Inner> {
    type Inner: Zeroize;

    // Required method
    fn new(inner: Self::Inner) -> Self;
}
Expand description

A trait implemented by secret microtypes

Due to their nature, secret microtypes are more restrictive than regular microtypes:

  • inner, inner_mut and into_inner are removed, since they can allow accidental use of the contained secret.
  • SecretMicrotype requires ExposeSecret<Self::Inner>; to use the contained data, use .expose_secret()

The wrapped type must also implement secrecy::Zeroize

Required Associated Types§

Source

type Inner: Zeroize

The type of the wrapped value For example, the inner type of a Password could be a String

Required Methods§

Source

fn new(inner: Self::Inner) -> Self

Create a microtype from the inner value

Note that it is not possible to retrieve the owned value, it can only be read via shared reference obtained via expose_secret()

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§