Skip to main content

SecretOutput

Struct SecretOutput 

Source
pub struct SecretOutput<'a> { /* private fields */ }
Expand description

Borrowed secret output with full-range cleanup on drop.

Construction wipes unused tail bytes. Drop wipes the complete borrowed range. A consuming Self::declassify call deliberately transfers the bytes into an ordinary non-wiping view.

Implementations§

Source§

impl<'a> SecretOutput<'a>

Source

pub fn from_initialized( storage: &'a mut [u8], len: usize, ) -> Result<Self, BufferLengthError>

Wraps one initialized prefix and assumes cleanup responsibility.

Invalid lengths wipe the complete range before returning an error.

Source

pub fn empty(storage: &'a mut [u8]) -> Self

Creates an empty output guard after wiping the complete range.

Source

pub fn expose_secret(&self) -> ExposedSecret<'_>

Creates an explicit borrowed interoperability view.

Source

pub fn expose_secret_mut(&mut self) -> ExposedSecretMut<'_>

Creates an explicit mutable interoperability view.

Source

pub fn declassify(self) -> DeclassifiedOutput<'a>

Deliberately transfers the initialized prefix into ordinary storage.

The returned view does not wipe on drop. Its tail remains zeroed, and the caller becomes responsible for any later cleanup requirement.

Source

pub const fn len(&self) -> usize

Returns the public initialized length.

Source

pub fn capacity(&self) -> usize

Returns the public borrowed capacity.

Source

pub const fn is_empty(&self) -> bool

Returns whether the initialized prefix is empty.

Source

pub fn clear(&mut self)

Wipes the complete range and resets the initialized length.

Trait Implementations§

Source§

impl Debug for SecretOutput<'_>

Source§

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

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

impl Display for SecretOutput<'_>

Source§

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

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

impl Drop for SecretOutput<'_>

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§

§

impl<'a> !UnwindSafe for SecretOutput<'a>

§

impl<'a> Freeze for SecretOutput<'a>

§

impl<'a> RefUnwindSafe for SecretOutput<'a>

§

impl<'a> Send for SecretOutput<'a>

§

impl<'a> Sync for SecretOutput<'a>

§

impl<'a> Unpin for SecretOutput<'a>

§

impl<'a> UnsafeUnpin for SecretOutput<'a>

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.