Skip to main content

SensitiveDisplay

Derive Macro SensitiveDisplay 

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

Derives redactable::RedactableDisplay using a display template.

This generates a redacted string representation without requiring Clone. Unannotated fields use RedactableDisplay by default (passthrough for scalars, redacted display for nested SensitiveDisplay types).

§Container Attributes

  • #[sensitive(skip_debug)] - Opt out of Debug impl generation. Use this when you need a custom Debug implementation or the type already derives Debug elsewhere.

§Field Annotations

  • (none): Uses RedactableDisplay (requires the field type to implement it)
  • #[sensitive(Policy)]: Apply the policy’s redaction rules
  • #[not_sensitive]: Render raw via Display (use for types without RedactableDisplay)

The display template is taken from #[error("...")] (thiserror-style) or from doc comments (displaydoc-style). If neither is present, the derive fails.

Fields are redacted by reference, so field types do not need Clone.

§Additional Generated Impls

  • Debug: when not building with cfg(any(test, feature = "testing")), Debug formats via RedactableDisplay::fmt_redacted. In test/testing builds, it shows actual values for debugging.