Skip to main content

NotSensitive

Derive Macro NotSensitive 

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

Derives a no-op redactable::RedactableWithMapper implementation, along with slog::Value / SlogRedacted and TracingRedacted.

This is useful for types that are known to be non-sensitive but still need to satisfy RedactableWithMapper / Redactable bounds. Because the type has no sensitive data, logging integration works without wrappers.

§Generated Impls

  • RedactableWithMapper: no-op passthrough (the type has no sensitive data)
  • Redactable: declares the type public and allows it inside Sensitive containers.
  • ToRedacted: always generated; emits the raw Serialize output the author declared public. This is why NotSensitive requires serde::Serialize; Clone is not required, because nothing is redacted.
  • slog::Value and SlogRedacted (behind cfg(feature = "slog")): serializes the explicitly non-sensitive value directly as structured JSON. Requires Serialize on the type. Serialization borrows the value without cloning it. Serde reports an active mutable RefCell borrow as an error, which becomes "[REDACTED]".
  • TracingRedacted (behind cfg(feature = "tracing")): marker trait

NotSensitive does not generate a Debug impl - there’s nothing to redact. Use #[derive(Debug)] when needed.

§Rejected Attributes

#[sensitive] and #[not_sensitive] attributes are rejected on both the container and its fields - the former is wrong (the type is explicitly non-sensitive), the latter is redundant (the entire type is already non-sensitive).

Unions are rejected at compile time.