pub struct ConfigSecret<T>(/* private fields */);Expand description
A wrapper type for sensitive configuration values that should never be printed.
IMPORTANT: This type is only designed for configuration secrets and should not be used for other purposes. It does not provide protection against memory inspection, it does not zeroize the memory on drop, and may be sensible to time-based attacks.
This type implements Debug and Display to always show [REDACTED] instead
of the actual value, preventing accidental exposure in logs or console output.
Note on Serialization: When serialized, this type always outputs "[REDACTED]"
regardless of the inner value.
Deserialization works normally, parsing the actual value.
This asymmetry is intentional to prevent accidental secret exposure in serialized output.
Implementations§
Source§impl<T> ConfigSecret<T>
impl<T> ConfigSecret<T>
Sourcepub fn expose_secret(&self) -> &T
pub fn expose_secret(&self) -> &T
Exposes the inner secret value.
Use this method carefully and only when you actually need the secret value.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the wrapper and returns the inner secret value.
Trait Implementations§
Source§impl<T: Clone> Clone for ConfigSecret<T>
impl<T: Clone> Clone for ConfigSecret<T>
Source§impl<T> Debug for ConfigSecret<T>
impl<T> Debug for ConfigSecret<T>
Source§impl<T: Default> Default for ConfigSecret<T>
impl<T: Default> Default for ConfigSecret<T>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for ConfigSecret<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for ConfigSecret<T>
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>,
Source§impl<T> Display for ConfigSecret<T>
impl<T> Display for ConfigSecret<T>
Source§impl<T> From<T> for ConfigSecret<T>
impl<T> From<T> for ConfigSecret<T>
Source§impl<T: FromStr> FromStr for ConfigSecret<T>
impl<T: FromStr> FromStr for ConfigSecret<T>
Source§impl<T: Hash> Hash for ConfigSecret<T>
impl<T: Hash> Hash for ConfigSecret<T>
Source§impl<T: PartialEq> PartialEq for ConfigSecret<T>
impl<T: PartialEq> PartialEq for ConfigSecret<T>
Source§impl<T: Serialize> Serialize for ConfigSecret<T>
impl<T: Serialize> Serialize for ConfigSecret<T>
impl<T: Eq> Eq for ConfigSecret<T>
Auto Trait Implementations§
impl<T> Freeze for ConfigSecret<T>where
T: Freeze,
impl<T> RefUnwindSafe for ConfigSecret<T>where
T: RefUnwindSafe,
impl<T> Send for ConfigSecret<T>where
T: Send,
impl<T> Sync for ConfigSecret<T>where
T: Sync,
impl<T> Unpin for ConfigSecret<T>where
T: Unpin,
impl<T> UnwindSafe for ConfigSecret<T>where
T: UnwindSafe,
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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