pub struct SecretBuffer { /* private fields */ }Expand description
Owned sensitive bytes with redacted formatting and drop-time cleanup.
SecretBuffer is available with the alloc feature. It is intended for
decoded keys, tokens, and other values that should not be accidentally
logged. The buffer exposes contents only through explicit reveal methods.
On drop, initialized bytes are cleared with the crate’s internal best-effort wipe helper. This is data-retention reduction, not a formal zeroization guarantee, and it cannot make claims about allocator spare capacity or historical copies outside the wrapper.
Implementations§
Source§impl SecretBuffer
impl SecretBuffer
Sourcepub fn from_slice(bytes: &[u8]) -> Self
pub fn from_slice(bytes: &[u8]) -> Self
Copies a slice into an owned sensitive buffer.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the buffer contains no initialized secret bytes.
Sourcepub fn expose_secret(&self) -> &[u8] ⓘ
pub fn expose_secret(&self) -> &[u8] ⓘ
Reveals the secret bytes.
This method is intentionally named to make secret access explicit at the call site.
Sourcepub fn expose_secret_mut(&mut self) -> &mut [u8] ⓘ
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.
Trait Implementations§
Source§impl Clone for SecretBuffer
Available on crate feature alloc only.
impl Clone for SecretBuffer
alloc only.Source§impl Debug for SecretBuffer
Available on crate feature alloc only.
impl Debug for SecretBuffer
alloc only.Source§impl Display for SecretBuffer
Available on crate feature alloc only.
impl Display for SecretBuffer
alloc only.Source§impl Drop for SecretBuffer
Available on crate feature alloc only.
impl Drop for SecretBuffer
alloc only.Source§impl PartialEq for SecretBuffer
Available on crate feature alloc only.
impl PartialEq for SecretBuffer
alloc only.impl Eq for SecretBuffer
alloc only.