pub struct Secret(/* private fields */);Expand description
A secret value — an API token, a password — that redacts itself whenever
it is formatted, so it can’t leak into a log line or an error message. Read
the underlying value only at the point of use, via expose.
Redaction is the achievable guarantee here; this type does not securely scrub its memory on drop.
Deliberately not PartialEq/Eq: comparing secrets with String’s
short-circuiting == is timing-variable and turns the type into an equality
oracle. Compare the exposed value explicitly if you must.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Secret
impl RefUnwindSafe for Secret
impl Send for Secret
impl Sync for Secret
impl Unpin for Secret
impl UnsafeUnpin for Secret
impl UnwindSafe for Secret
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