Skip to main content

BoundedLockedSecretString

Struct BoundedLockedSecretString 

Source
pub struct BoundedLockedSecretString<const MAX: usize> { /* private fields */ }
Expand description

Locked UTF-8 text with a permanent type-level byte maximum.

Implementations§

Source§

impl<const MAX: usize> BoundedLockedSecretString<MAX>

Source

pub const fn max_len() -> usize

Source

pub fn try_with_capacity_with_protection( capacity: usize, request: ProtectionRequest, ) -> Result<Self, ProtectedSecretTextFillError<Infallible>>

Construct empty bounded UTF-8 storage after required controls succeed.

Source

pub fn try_from_capacity_with_protection<E>( capacity: usize, request: ProtectionRequest, fill: impl FnOnce(&mut [u8]) -> Result<usize, E>, ) -> Result<Self, ProtectedSecretTextFillError<E>>

Fill bounded locked UTF-8 storage after required controls succeed.

Source

pub fn try_from_exact_len_with_protection<E>( len: usize, request: ProtectionRequest, fill: impl FnOnce(&mut [u8]) -> Result<(), E>, ) -> Result<Self, ProtectedSecretTextFillError<E>>

Fill an exact-length bounded locked UTF-8 value in place.

Source

pub fn from_secret_str_with_protection( text: &str, request: ProtectionRequest, ) -> Result<Self, ProtectedSecretTextFillError<Infallible>>

Copy UTF-8 text after required controls are established.

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub const fn backing_capacity(&self) -> usize

Source

pub const fn locked_len(&self) -> usize

Source

pub const fn is_memory_locked(&self) -> bool

Returns true when the mapping is locked against ordinary paging.

Source

pub const fn protection_report(&self) -> &ProtectionReport

Source

pub const fn protection_request(&self) -> ProtectionRequest

Source

pub fn try_with_secret<R>( &self, inspect: impl FnOnce(&str) -> R, ) -> Result<R, SecretTextIntegrityError>

Source

pub fn try_with_secret_mut<R>( &mut self, edit: impl FnOnce(&mut str) -> R, ) -> Result<R, SecretTextIntegrityError>

Source

pub fn try_push_str( &mut self, text: &str, ) -> Result<(), BoundedMappedSecretError<MemoryLockError>>

Source

pub fn try_replace_from_secret_str( &mut self, text: &str, ) -> Result<(), BoundedMappedSecretError<MemoryLockError>>

Source

pub fn clear_secret(&mut self)

Source

pub fn try_constant_time_eq( &self, other: &str, ) -> Result<bool, CanaryCorruptedError>

Source

pub fn verify_integrity(&self) -> Result<(), CanaryCorruptedError>

Trait Implementations§

Source§

impl<const MAX: usize> ConstantTimeEq for BoundedLockedSecretString<MAX>

Available on non-WebAssembly only.
Source§

fn ct_eq(&self, other: &Self) -> Choice

Compare without secret-dependent early exit.
Source§

fn ct_ne(&self, other: &Rhs) -> Choice

Source§

impl<const MAX: usize> ConstantTimeEq for BoundedLockedSecretString<MAX>

Available on crate feature memory-lock and non-WebAssembly only.
Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl<const MAX: usize> ConstantTimeEq<str> for BoundedLockedSecretString<MAX>

Available on non-WebAssembly only.
Source§

fn ct_eq(&self, other: &str) -> Choice

Compare without secret-dependent early exit.
Source§

fn ct_ne(&self, other: &Rhs) -> Choice

Source§

impl<const MAX: usize> Debug for BoundedLockedSecretString<MAX>

Available on crate feature memory-lock and (Android, or DragonFly BSD, or FreeBSD, or iOS, or macOS, or NetBSD, or OpenBSD, or Windows, or Linux and (AArch64 or x86-64)) only.
Source§

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

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

impl<const MAX: usize> SecureSanitize for BoundedLockedSecretString<MAX>

Available on crate feature memory-lock and (Android, or DragonFly BSD, or FreeBSD, or iOS, or macOS, or NetBSD, or OpenBSD, or Windows, or Linux and (AArch64 or x86-64)) only.
Source§

fn secure_sanitize(&mut self)

Clear the sensitive bytes owned by this value.
Source§

impl<const MAX: usize> Zeroize for BoundedLockedSecretString<MAX>

Available on crate feature memory-lock and non-WebAssembly only.
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<const MAX: usize> ZeroizeOnDrop for BoundedLockedSecretString<MAX>

Available on crate feature memory-lock and non-WebAssembly only.

Auto Trait Implementations§

§

impl<const MAX: usize> !Freeze for BoundedLockedSecretString<MAX>

§

impl<const MAX: usize> !RefUnwindSafe for BoundedLockedSecretString<MAX>

§

impl<const MAX: usize> !Sync for BoundedLockedSecretString<MAX>

§

impl<const MAX: usize> Send for BoundedLockedSecretString<MAX>

§

impl<const MAX: usize> Unpin for BoundedLockedSecretString<MAX>

§

impl<const MAX: usize> UnsafeUnpin for BoundedLockedSecretString<MAX>

§

impl<const MAX: usize> UnwindSafe for BoundedLockedSecretString<MAX>

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, 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.