Expand description
Type-directed redaction for structured data.
This crate separates:
- Classification: what kind of sensitive data this is.
- Policy: 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().
Key rules:
- Use
#[sensitive(Classification)]for string-like leaf values. - Use
#[sensitive]for scalars and nestedSensitivetypes. - Unannotated fields pass through unchanged.
Debugalways prints"[REDACTED]"for sensitive fields; policies apply only when calling.redact().
Boxed trait objects:
#[sensitive]supportsBox<dyn Trait>by callingredact_boxed.- Detection is conservative and only matches the simple
Box<dyn Trait>syntax, not qualified paths or type aliases.
What this crate does:
- defines classification marker types and the
Classificationtrait - defines redaction policies and the
redactentrypoint - provides integrations behind feature flags (e.g.
slog)
What it does not do:
- perform I/O or logging
- validate your policy choices
The Sensitive derive macro lives in redaction-derive and is re-exported when
the derive feature is enabled.
Structs§
- Account
Id - Classification marker for account identifiers.
- Blockchain
Address - Classification marker for blockchain addresses (e.g., Ethereum, Bitcoin).
- Credit
Card - Classification marker for credit card numbers or PANs.
- Date
OfBirth - Classification marker for dates of birth.
- Classification marker for email addresses.
- IpAddress
- Classification marker for IP addresses.
- Keep
Config - Configuration that keeps selected segments visible while masking the remainder.
- Mask
Config - Configuration that masks selected segments while leaving the remainder unchanged.
- National
Id - Classification marker for government-issued identifiers.
- Phone
Number - Classification marker for phone numbers.
- Pii
- Classification marker for personally identifiable information.
- Secret
- Classification marker for secrets such as passwords or private keys.
- Session
Id - Classification marker for session identifiers.
- Token
- Classification marker for authentication tokens and API keys.
Enums§
- Text
Redaction Policy - A redaction strategy for string-like values.
Constants§
- REDACTED_
PLACEHOLDER - Default placeholder used for full redaction.
Traits§
- Classification
- Marker trait for classification categories.
- Redactable
- Public entrypoint for redaction on traversable types.
- Redactable
Boxed - Redacts boxed trait objects that expose their own boxed redaction.
- Redaction
Policy - Associates a classification type with a concrete string redaction policy.
- Sensitive
Value - String-like payloads that can be redacted via policies.
Functions§
- apply_
classification - Applies a classification policy to a classifiable value.
- redact
- Redacts a value using classification-bound policies.
- redact_
boxed - Convenience helper for redacting boxed trait objects.
Derive Macros§
- Sensitive
- Derives
redaction::SensitiveType(and related impls) for structs and enums. - Sensitive
Error - Derives
redaction::SensitiveTypefor types that should log withoutSerialize.