pub struct SecretString(/* private fields */);Expand description
A secret string that is securely zeroed from memory when dropped.
This type is only available when the zeroize feature is enabled.
It ensures that sensitive data like passwords and tokens are overwritten
with zeros when they go out of scope.
Implementations§
Source§impl SecretString
impl SecretString
Sourcepub fn new(value: impl Into<String>) -> SecretString
pub fn new(value: impl Into<String>) -> SecretString
Create a new secret string.
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Get the secret value.
§Security
Be careful with the returned reference - avoid logging or copying the value unnecessarily.
Trait Implementations§
Source§impl Clone for SecretString
impl Clone for SecretString
Source§fn clone(&self) -> SecretString
fn clone(&self) -> SecretString
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecretString
Available on crate feature zeroize only.
impl Debug for SecretString
Available on crate feature
zeroize only.Source§impl Drop for SecretString
impl Drop for SecretString
Source§impl From<&str> for SecretString
Available on crate feature zeroize only.
impl From<&str> for SecretString
Available on crate feature
zeroize only.Source§fn from(s: &str) -> SecretString
fn from(s: &str) -> SecretString
Converts to this type from the input type.
Source§impl From<String> for SecretString
Available on crate feature zeroize only.
impl From<String> for SecretString
Available on crate feature
zeroize only.Source§fn from(s: String) -> SecretString
fn from(s: String) -> SecretString
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for SecretString
impl RefUnwindSafe for SecretString
impl Send for SecretString
impl Sync for SecretString
impl Unpin for SecretString
impl UnsafeUnpin for SecretString
impl UnwindSafe for SecretString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more