pub struct Redacted<T>(/* private fields */);Expand description
A value that prints as [redacted] in Display and Debug.
Wrap secrets (passwords, tokens, keys) and personal data held in an
error, so they never reach Display, Debug, dev_message, the log
adapters, or an ErrorCollector summary.
The default define_errors! format prints every field with Debug,
so a Redacted field prints as [redacted] there too. Read the
value with expose where it is really needed.
Redacted only changes how the value is printed. It does not wipe
memory and is not a cryptographic protection.
§Example
use error_forge::Redacted;
let token = Redacted::new(String::from("hunter2"));
assert_eq!(format!("{token}"), "[redacted]");
assert_eq!(format!("{token:?}"), "[redacted]");
assert_eq!(token.expose(), "hunter2");Implementations§
Trait Implementations§
impl<T: Copy> Copy for Redacted<T>
impl<T: Eq> Eq for Redacted<T>
impl<T: PartialEq> StructuralPartialEq for Redacted<T>
Auto Trait Implementations§
impl<T> Forget for Redacted<T>
impl<T> Freeze for Redacted<T>where
T: Freeze,
impl<T> Move for Redacted<T>
impl<T> RefUnwindSafe for Redacted<T>where
T: RefUnwindSafe,
impl<T> Send for Redacted<T>where
T: Send,
impl<T> Sync for Redacted<T>where
T: Sync,
impl<T> Unpin for Redacted<T>where
T: Unpin,
impl<T> UnsafeUnpin for Redacted<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Redacted<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
Mutably borrows from an owned value. Read more