#[derive(SensitiveDisplay)]
{
// Attributes available to this derive:
#[sensitive]
#[not_sensitive]
#[redactable]
#[error]
}
Expand description
Derives redactable::RedactableWithFormatter using a display template.
This generates a redacted string representation by borrowing the source.
The text/secret route needs no Clone; IP-map formatting clones keys and the HashMap hasher.
Referenced unannotated fields require declared formatting, such as a nested
SensitiveDisplay type. Unreferenced fields and constant templates remain supported.
§Field Annotations
- (none): Uses
RedactableWithFormatterand the publicredactable::DeclaredFormattingdeclaration #[sensitive(Policy)]: Apply the policy’s redaction rules#[not_sensitive]: Render raw viaDisplay(use for types withoutRedactableWithFormatter)
The display template is taken from #[error("...")] (thiserror-style) or from
doc comments (displaydoc-style). If neither is present, the derive fails.
§Policy Formatting
A custom leaf supports policy formatting by implementing
redactable::PolicyFormat. Supported containers forward
to their contents. A nested RefCell borrow conflict renders as <borrowed>.
Generic policy fields declare PolicyDisplay<P> for {value},
PolicyDebug<P> for {value:?}, or both when both modes are used.
The same requirements apply to concrete policy fields.
These policy-specific bounds permit supported scalars and typed IP addresses
without requiring structural Redactable or Clone. Missing capabilities
reject the declaration even when no formatting method is called.
Use SensitiveDual instead when the same type also needs structural redaction.
Its declarations must satisfy both structural and template capabilities.
§Generated Impls
RedactableWithFormatter: always generated.ToRedacted: always generated; emits the redacted display text forslog_redacted()andtracing_redacted().Debug: uses the production redacted representation in every build mode.slog::Value+SlogRedacted: emits the redacted display string (requiresslogfeature).TracingRedacted: marker trait (requirestracingfeature).