Skip to main content

ExposedSecretVec

Struct ExposedSecretVec 

Source
pub struct ExposedSecretVec { /* private fields */ }
Expand description

Owned secret bytes extracted from SecretBuffer.

This wrapper keeps redacted formatting, best-effort spare-capacity clearing at construction time, and best-effort full wipe on drop after a SecretBuffer is consumed for owned interop. Use Self::into_exposed_unprotected_vec_caller_must_zeroize only when a raw Vec<u8> is unavoidable and the caller will handle cleanup.

Implementations§

Source§

impl ExposedSecretVec

Source

pub fn from_vec(bytes: Vec<u8>) -> Self

Wraps an owned vector as exposed secret material.

Source

pub fn len(&self) -> usize

Returns the number of initialized secret bytes.

Source

pub fn is_empty(&self) -> bool

Returns whether the buffer contains no initialized secret bytes.

Source

pub fn expose_secret(&self) -> &[u8]

Reveals the secret bytes.

This method is intentionally named to make secret access explicit at the call site.

Source

pub fn expose_secret_mut(&mut self) -> &mut [u8]

Reveals the secret bytes mutably.

This method is intentionally named to make secret access explicit at the call site.

Source

pub fn into_exposed_unprotected_vec_caller_must_zeroize(self) -> Vec<u8>

Consumes the wrapper and returns a raw Vec<u8>.

This is an unprotected escape hatch. The returned vector is no longer redacted by formatting and will not be cleared by this crate on drop. Callers must clear it with their own approved zeroization policy.

Trait Implementations§

Source§

impl AsMut<[u8]> for ExposedSecretVec

Available on crate feature alloc only.
Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for ExposedSecretVec

Available on crate feature alloc only.
Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for ExposedSecretVec

Available on crate feature alloc only.
Source§

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

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

impl Display for ExposedSecretVec

Available on crate feature alloc only.
Source§

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

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

impl Drop for ExposedSecretVec

Available on crate feature alloc only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.