Crate redactrs

Source
Expand description

Wrapper for sensitive data that you want to avoid being leaked by accidentally printing/logging/etc. them.

How the data is redacted is defined by the Redactor. A Redactor is a struct that implements the Redactor-trait.

§Usage

In it’s most basic form, Redacted is used like this:

let x: Redacted<&str> = "sensitive".into();

assert_eq!(x.to_string(), "<redacted>");

This will by default use the Simple-Redactor. If desired, it can be swapped with the Custom-Redactor.

let x: Redacted<&str, Custom<'X', 5>> = "sensitive".into();

assert_eq!(x.to_string(), "XXXXX");

To get back the wrapped type use:

  • .into_inner() which consumes the Redacted and returns the wrapped type.
  • .inner() to get a reference of the wrapped type.
  • .inner_mut() to get a mutable reference of the wrapped tyepe.

NOTE: a Redacted is always constructed via the From/Into trait.

Modules§

Structs§

  • Struct used to wrap sensitive content that should not be printed/logged. The redaction behaviour is defined by Redactor.

Traits§

  • A Trait to define how a value should be redacted.