pub struct Secret(/* private fields */);Expand description
A string secret that redacts itself in Debug output.
Wrapping a credential field in Secret makes a containing struct’s
derived Debug print <redacted> for that field, so a future
tracing::debug!("{creds:?}") or .context(format!("… {creds:?}"))
cannot leak the value into logs or error chains.
Secret implements neither Display nor serde traits by design; the
wrapped value is only reachable through
expose_secret.
§Examples
use omni_dev::utils::secret::Secret;
let token = Secret::new("s3cr3t");
assert_eq!(format!("{token:?}"), "<redacted>");
assert_eq!(token.expose_secret(), "s3cr3t");Implementations§
Trait Implementations§
impl Eq for Secret
impl StructuralPartialEq for Secret
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.