#[derive(Sensitive)]
{
// Attributes available to this derive:
#[sensitive]
}
Expand description
Derives redactable::RedactableContainer (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 is traversed by default. Scalars pass through unchanged; nested structs/enums are walked using
RedactableContainer(so external types must implement it). -
#[sensitive(Default)]: For scalar types (i32, bool, char, etc.), redacts to default values (0, false, ‘*’). For string-like types, applies full redaction to"[REDACTED]". -
#[sensitive(Policy)]: Applies the policy’s redaction rules to string-like values. Works forString,Option<String>,Vec<String>,Box<String>. Scalars can only use#[sensitive(Default)].
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 throughredactable::slog::SlogRedactedExt. Note: this impl requiresCloneandserde::Serializebecause it emits structured JSON. The derive first looks for a top-levelslogcrate; if not found, it checks theREDACTABLE_SLOG_CRATEenv var for an alternate path (e.g.,my_log::slog). If neither is available, compilation fails with a clear error.