Skip to main content

NotSensitiveDisplay

Derive Macro NotSensitiveDisplay 

Source
#[derive(NotSensitiveDisplay)]
{
    // Attributes available to this derive:
    #[sensitive]
    #[not_sensitive]
}
Expand description

Derives redactable::RedactableWithFormatter for types with no sensitive data.

This is the display counterpart to NotSensitive. Use it when you have a type with no sensitive data that needs logging integration (e.g., for use with slog).

Unlike SensitiveDisplay, this derive does not require a display template. Instead, it delegates directly to the type’s existing Display implementation.

§Required Bounds

The type must implement Display. This is required because RedactableWithFormatter delegates to Display::fmt.

§Generated Impls

  • RedactableWithMapper: no-op passthrough (allows use inside Sensitive containers)
  • Redactable: deriving NotSensitiveDisplay is an explicit declaration, so the type is certified for consuming and borrowed adapters.
  • RedactableWithFormatter: delegates to Display::fmt
  • ToRedactedOutput: emits the Display text; certifies the type for slog_redacted_display() and tracing_redacted()
  • slog::Value and SlogRedacted (behind cfg(feature = "slog")): uses RedactableWithFormatter output
  • TracingRedacted (behind cfg(feature = "tracing")): marker trait

§Debug

NotSensitiveDisplay does not generate a Debug impl - there’s nothing to redact. Use #[derive(Debug)] alongside NotSensitiveDisplay when needed.

§Rejected Attributes

#[sensitive] and #[not_sensitive] attributes are rejected on both the container and its fields - the former is wrong (the type is explicitly non-sensitive), the latter is redundant (the entire type is already non-sensitive).

§Example

use redactable::NotSensitiveDisplay;
use std::fmt;

#[derive(NotSensitiveDisplay)]
enum RetryDecision {
    Retry,
    Abort,
}

impl fmt::Display for RetryDecision {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter.write_str(match self {
            Self::Retry => "Retry",
            Self::Abort => "Abort",
        })
    }
}

assert_eq!(RetryDecision::Retry.to_string(), "Retry");