pub struct ExposedSecretString { /* private fields */ }Expand description
Owned secret UTF-8 text 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 string interop. Use
Self::into_exposed_unprotected_string_caller_must_zeroize only when a
raw String is unavoidable and the caller will handle cleanup.
Implementations§
Source§impl ExposedSecretString
impl ExposedSecretString
Sourcepub fn from_string(text: String) -> Self
pub fn from_string(text: String) -> Self
Wraps an owned UTF-8 string as exposed secret text.
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Reveals the secret text.
This method is intentionally named to make secret access explicit at the call site.
Sourcepub fn expose_secret_bytes(&self) -> &[u8] ⓘ
pub fn expose_secret_bytes(&self) -> &[u8] ⓘ
Reveals the secret text as bytes.
This method is intentionally named to make secret access explicit at the call site.
Sourcepub fn into_exposed_unprotected_string_caller_must_zeroize(self) -> String
pub fn into_exposed_unprotected_string_caller_must_zeroize(self) -> String
Consumes the wrapper and returns a raw String.
This is an unprotected escape hatch. The returned string 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 AsRef<str> for ExposedSecretString
Available on crate feature alloc only.
impl AsRef<str> for ExposedSecretString
alloc only.Source§impl Debug for ExposedSecretString
Available on crate feature alloc only.
impl Debug for ExposedSecretString
alloc only.Source§impl Display for ExposedSecretString
Available on crate feature alloc only.
impl Display for ExposedSecretString
alloc only.Source§impl Drop for ExposedSecretString
Available on crate feature alloc only.
impl Drop for ExposedSecretString
alloc only.