pub struct RedactedString(/* private fields */);Expand description
A string newtype that hides its contents from Debug formatting.
Use for API secrets, passwords, and other credentials that must never appear in logs. Serializes/deserializes transparently as a plain string so the wire format is unchanged.
Call Self::expose_secret to access the underlying value when you
genuinely need it (e.g. to authenticate a request).
Implementations§
Source§impl RedactedString
impl RedactedString
Sourcepub fn new(s: impl Into<String>) -> Self
pub fn new(s: impl Into<String>) -> Self
Wrap a string. Prefer From<String> / From<&str> in code.
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Access the underlying secret. Use sparingly; never log the return value of this method.
Trait Implementations§
Source§impl Clone for RedactedString
impl Clone for RedactedString
Source§fn clone(&self) -> RedactedString
fn clone(&self) -> RedactedString
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 RedactedString
impl Debug for RedactedString
Source§impl Default for RedactedString
impl Default for RedactedString
Source§fn default() -> RedactedString
fn default() -> RedactedString
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for RedactedString
impl<'de> Deserialize<'de> for RedactedString
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for RedactedString
Source§impl From<&str> for RedactedString
impl From<&str> for RedactedString
Source§impl From<String> for RedactedString
impl From<String> for RedactedString
Source§impl PartialEq for RedactedString
impl PartialEq for RedactedString
Source§fn eq(&self, other: &RedactedString) -> bool
fn eq(&self, other: &RedactedString) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for RedactedString
impl Serialize for RedactedString
impl StructuralPartialEq for RedactedString
Auto Trait Implementations§
impl Freeze for RedactedString
impl RefUnwindSafe for RedactedString
impl Send for RedactedString
impl Sync for RedactedString
impl Unpin for RedactedString
impl UnsafeUnpin for RedactedString
impl UnwindSafe for RedactedString
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.