DisplayRedacted

Trait DisplayRedacted 

Source
pub trait DisplayRedacted {
    // Required methods
    fn fmt_redacted(&self, f: &mut Formatter<'_>) -> Result;
    fn fmt_unredacted(&self, f: &mut Formatter<'_>) -> Result;

    // Provided methods
    fn display_redacted(&self) -> impl Display + '_ { ... }
    fn display_unredacted(&self) -> impl Display + '_ { ... }
}
Expand description

A type that can be displayed in a redacted or un-redacted form, but which forces the caller to choose.

See Redactable for more discussion on redaction.

Unlike Redactable, this type is “inherently sensitive”: Types implementing DisplayRedacted should not typically implement Display.

For external types that implement Display, or for types which are usually not sensitive, Redacted is likely a better choice.

Required Methods§

Source

fn fmt_redacted(&self, f: &mut Formatter<'_>) -> Result

As Display::fmt, but write this object in its redacted form.

Source

fn fmt_unredacted(&self, f: &mut Formatter<'_>) -> Result

As Display::fmt, but write this object in its un-redacted form.

Provided Methods§

Source

fn display_redacted(&self) -> impl Display + '_

Return a pointer wrapping this object that can be Displayed in redacted form if safe-logging is enabled.

(If safe-logging is not enabled, it will de displayed in its unredacted form.)

Source

fn display_unredacted(&self) -> impl Display + '_

Return a pointer wrapping this object that can be Displayed in unredacted form.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T> DisplayRedacted for &'a T
where T: DisplayRedacted + ?Sized,

Source§

fn display_redacted(&self) -> impl Display + '_

Source§

fn display_unredacted(&self) -> impl Display + '_

Source§

fn fmt_redacted(&self, f: &mut Formatter<'_>) -> Result

Source§

fn fmt_unredacted(&self, f: &mut Formatter<'_>) -> Result

Implementors§