Skip to main content

Sensitive

Derive Macro Sensitive 

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

Derives redaction::SensitiveType (and related impls) for structs and enums.

§Container Attributes

These attributes are placed on the struct/enum itself:

  • #[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 Attributes

  • No annotation: The field passes through unchanged. Use this for fields that don’t contain sensitive data, including external types like chrono::DateTime or rust_decimal::Decimal.

  • #[sensitive]: For scalar types (i32, bool, char, etc.), redacts to default values (0, false, ‘X’). For struct/enum types that derive Sensitive, walks into them using SensitiveType.

  • #[sensitive(Classification)]: Treats the field as a sensitive string-like value and applies the classification’s policy. Works for String, Option<String>, Vec<String>, Box<String>. The type must implement SensitiveValue.

Unions are rejected at compile time.

§Additional Generated Impls

  • Debug: when not building with cfg(any(test, feature = "testing")), sensitive fields are formatted as the string "[REDACTED]" rather than their values. Use #[sensitive(skip_debug)] on the container to opt out.
  • slog::Value (behind cfg(feature = "slog")): implemented by cloning the value and routing it through redaction::slog::IntoRedactedJson. Note: this impl requires the type to implement Clone.