#[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 ofDebugimpl generation. Use this when you need a customDebugimplementation or the type already derivesDebugelsewhere.
§Field Attributes
-
No annotation: The field passes through unchanged. Use this for fields that don’t contain sensitive data, including external types like
chrono::DateTimeorrust_decimal::Decimal. -
#[sensitive]: For scalar types (i32, bool, char, etc.), redacts to default values (0, false, ‘X’). For struct/enum types that deriveSensitive, walks into them usingSensitiveType. -
#[sensitive(Classification)]: Treats the field as a sensitive string-like value and applies the classification’s policy. Works forString,Option<String>,Vec<String>,Box<String>. The type must implementSensitiveValue.
Unions are rejected at compile time.
§Additional Generated Impls
Debug: when not building withcfg(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(behindcfg(feature = "slog")): implemented by cloning the value and routing it throughredaction::slog::IntoRedactedJson. Note: this impl requires the type to implementClone.