pub struct SecretString(/* private fields */);Expand description
A string holding a sensitive value whose contents are never shown by
Debug or Display.
The inner value is accessible only via SecretString::expose. Equality is
provided for tests and lookup bookkeeping; it is not constant-time and
must not be used to compare secrets that an attacker can influence by timing
— compare derived crate::hashing::LookupKey values instead.
Implementations§
Source§impl SecretString
impl SecretString
Sourcepub fn new(value: String) -> Self
pub fn new(value: String) -> Self
Wrap a value as a secret. The value is moved in and never copied to any formatting buffer.
Sourcepub fn expose(&self) -> &str
pub fn expose(&self) -> &str
Borrow the plaintext. Named expose so its use is visible in review and
easy to grep for; callers must not log or persist the returned value.
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
impl Debug for SecretString
Source§impl Display for SecretString
impl Display for SecretString
impl Eq for SecretString
Source§impl PartialEq for SecretString
impl PartialEq for SecretString
Source§fn eq(&self, other: &SecretString) -> bool
fn eq(&self, other: &SecretString) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SecretString
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