Struct SecretToken
pub struct SecretToken(/* private fields */);Expand description
A sensitive token string that is zeroized on drop and hidden from debug output.
SecretToken wraps a String and enforces two invariants:
- Zeroized on drop: the backing memory is overwritten with zeros when the token goes out of scope, preventing it from lingering in memory.
- Opaque debug: the
Debugimplementation prints"***"instead of the actual value, so tokens won’t leak into logs or error messages.
Use SecretToken::new to wrap a string value (e.g. an access key
loaded from configuration or an environment variable).
Implementations§
Trait Implementations§
Source§impl Clone for SecretToken
impl Clone for SecretToken
Source§fn clone(&self) -> SecretToken
fn clone(&self) -> SecretToken
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 SecretToken
impl Debug for SecretToken
Source§impl<'de> Deserialize<'de> for SecretToken
impl<'de> Deserialize<'de> for SecretToken
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SecretToken, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SecretToken, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Drop for SecretToken
impl Drop for SecretToken
impl OpaqueDebug for SecretToken
Source§impl Serialize for SecretToken
impl Serialize for SecretToken
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for SecretToken
impl RefUnwindSafe for SecretToken
impl Send for SecretToken
impl Sync for SecretToken
impl Unpin for SecretToken
impl UnsafeUnpin for SecretToken
impl UnwindSafe for SecretToken
Blanket Implementations§
impl<T> AuthStrategyBounds for T
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
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more