Skip to main content

Crate redactable

Crate redactable 

Source
Expand description

Type-directed redaction for structured data.

This crate separates:

  • Policy markers: what kind of sensitive data this is (e.g., Pii, Token, Email).
  • Redaction policies: how that data should be redacted.

The derive macro walks your data and applies the policy at the boundary when you call redact() or Redactable::redact().

What this crate does:

  • defines policy marker types (e.g., Pii, Token, Email)
  • defines redaction policies and the redact entrypoint
  • provides integrations behind feature flags (e.g. slog)

What it does not do:

  • perform I/O or logging
  • validate your policy choices

Explicitly non-sensitive output remains an exceptional opt-in. Use NotSensitiveDebug or NotSensitiveDisplay only when the complete formatted value is safe to log. With the json feature, those wrappers serialize the raw inner value for transport or storage; Serde output is not redaction. Sensitive values should use SensitiveValue or a custom ToRedactedOutput projection instead.

The Sensitive derive macro lives in redactable-derive and is re-exported from this crate.

Re-exports§

pub use policy::BlockchainAddress;
pub use policy::CreditCard;
pub use policy::Email;
pub use policy::EmailConfig;
pub use policy::IpAddress;
pub use policy::KeepConfig;
pub use policy::MASK_CHAR;
pub use policy::MaskConfig;
pub use policy::PhoneNumber;
pub use policy::Pii;
pub use policy::REDACTED_PLACEHOLDER;
pub use policy::RedactionPolicy;
pub use policy::Secret;
pub use policy::TextRedactionPolicy;
pub use policy::Token;
pub use slog::RedactedDisplayValue;
pub use slog::SlogRedactedDisplayExt;
pub use slog::SlogRedactedExt;

Modules§

policy
Redaction policies: marker types and text transformations.
slog
Adapters for emitting redacted values through slog.
tracing
Adapters for emitting redacted values through tracing.

Structs§

NotSensitive
Wrapper for explicitly non-sensitive values without formatting opinions.
NotSensitiveDebug
Owns an explicitly non-sensitive value and emits its Debug representation.
NotSensitiveDisplay
Owns an explicitly non-sensitive value and emits its Display representation.
NotSensitiveJson
Wrapper for explicitly non-sensitive values using JSON serialization.
NotSensitiveValue
Wrapper for foreign types that should pass through unchanged.
RedactedFormatterRef
Display wrapper that uses RedactableWithFormatter::fmt_redacted.
RedactedJson
Owned redacted JSON output produced at logging boundaries.
RedactedJsonRef
Wrapper for redacted JSON output from structured types.
RedactedOutputRef
Wrapper for explicitly redacting structured types.
SensitiveValue
Wrapper for leaf values to apply a redaction policy.

Enums§

RedactedOutput
Output produced at a logging boundary.

Traits§

NotSensitiveDebugExt
Extension trait to mark values as explicitly non-sensitive using Debug.
NotSensitiveDisplayExt
Extension trait to mark values as explicitly non-sensitive using Display.
NotSensitiveExt
Extension trait to mark values as explicitly non-sensitive for logging.
NotSensitiveJsonExt
Extension trait to mark values as explicitly non-sensitive using JSON.
Redactable
Public entrypoint for redaction on types with declared redaction behavior.
RedactableWithFormatter
Formats a redacted string representation without requiring Clone or Serialize.
RedactedJsonExt
Extension trait to obtain a redacted JSON output wrapper.
RedactedOutputExt
Extension trait to obtain a redacted output wrapper.
SensitiveWithPolicy
A type that can be redacted using a specific policy.
ToRedactedOutput
Produces a logging-safe output representation.

Derive Macros§

NotSensitive
Derives a no-op redactable::RedactableWithMapper implementation, along with slog::Value / SlogRedacted and TracingRedacted.
NotSensitiveDisplay
Derives redactable::RedactableWithFormatter for types with no sensitive data.
Sensitive
Derives redactable::RedactableWithMapper (and related impls) for structs and enums.
SensitiveDisplay
Derives redactable::RedactableWithFormatter using a display template.