secrecy

Type Alias SecretSlice

Source
pub type SecretSlice<S> = SecretBox<[S]>;
Expand description

Secret slice type.

This is a type alias for [SecretBox<[S]>] which supports some helpful trait impls.

Notably it has a From<Vec<S>> impl which is the preferred method for construction.

Aliased Type§

struct SecretSlice<S> { /* private fields */ }

Implementations

Source§

impl<S: Zeroize + Clone> SecretBox<S>

Source

pub fn init_with(ctr: impl FnOnce() -> S) -> Self

Create a secret value using the provided function as a constructor.

The implementation makes an effort to zeroize the locally constructed value before it is copied to the heap, and constructing it inside the closure minimizes the possibility of it being accidentally copied by other code.

Note: using Self::new or Self::init_with_mut is preferable when possible, since this method’s safety relies on empiric evidence and may be violated on some targets.

Source

pub fn try_init_with<E>(ctr: impl FnOnce() -> Result<S, E>) -> Result<Self, E>

Same as Self::init_with, but the constructor can be fallible.

Note: using Self::new or Self::init_with_mut is preferable when possible, since this method’s safety relies on empyric evidence and may be violated on some targets.

Source§

impl<S: Zeroize + ?Sized> SecretBox<S>

Source

pub fn new(boxed_secret: Box<S>) -> Self

Create a secret value using a pre-boxed value.

Source§

impl<S: Zeroize + Default> SecretBox<S>

Source

pub fn init_with_mut(ctr: impl FnOnce(&mut S)) -> Self

Create a secret value using a function that can initialize the value in-place.

Trait Implementations§

Source§

impl<S> Clone for SecretSlice<S>

Source§

fn clone(&self) -> Self

Returns a copy 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<S> Default for SecretSlice<S>
where S: Zeroize, [S]: Zeroize,

Source§

fn default() -> Self

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

impl<S> From<Vec<S>> for SecretSlice<S>
where S: Zeroize, [S]: Zeroize,

Source§

fn from(vec: Vec<S>) -> Self

Converts to this type from the input type.
Source§

impl<S> Clone for SecretBox<S>
where S: CloneableSecret,

Source§

fn clone(&self) -> Self

Returns a copy 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<S: Zeroize + ?Sized> Debug for SecretBox<S>

Source§

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

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

impl<S: Zeroize + Default> Default for SecretBox<S>

Source§

fn default() -> Self

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

impl<S: Zeroize + ?Sized> Drop for SecretBox<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<S: Zeroize + ?Sized> ExposeSecret<S> for SecretBox<S>

Source§

fn expose_secret(&self) -> &S

Expose secret: this is the only method providing access to a secret.
Source§

impl<S: Zeroize + ?Sized> ExposeSecretMut<S> for SecretBox<S>

Source§

fn expose_secret_mut(&mut self) -> &mut S

Expose secret: this is the only method providing access to a secret.
Source§

impl<S: Zeroize + ?Sized> From<Box<S>> for SecretBox<S>

Source§

fn from(source: Box<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: Zeroize + ?Sized> Zeroize for SecretBox<S>

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<S: Zeroize + ?Sized> ZeroizeOnDrop for SecretBox<S>