pub trait Redactable: RedactableWithMapper {
// Provided method
fn redact(self) -> Self { ... }
}Expand description
Public entrypoint for redaction on types with declared redaction behavior.
Redactable is implemented by the Sensitive, NotSensitive, and
NotSensitiveDisplay derives, by SensitiveValue / NotSensitiveValue,
by serde_json::Value (with the json feature), and by std containers of
such types. It provides the redact() method and certifies the type for
the logging-boundary extension traits (RedactedOutputExt,
RedactedJsonExt, SlogRedactedExt).
Passthrough leaves like String and scalars deliberately do not
implement it: they participate in traversal (so unannotated fields work
inside derived containers), but nobody declared what redacting them means,
so calling redact() on them - or certifying them as redacted output -
must not compile.
Containers preserve that boundary: forwarding applies only when their contents are also certified.
use redactable::Redactable;
fn require_redactable<T: Redactable>(_: T) {}
require_redactable(std::collections::VecDeque::from([String::from("raw")]));
require_redactable([String::from("raw")]);
require_redactable((String::from("raw"),));
require_redactable(std::sync::Mutex::new(String::from("raw")));
require_redactable(std::sync::RwLock::new(String::from("raw")));redact is implemented in terms of the default mapping behavior provided by
[super::redact::redact], which applies policies associated with policy
marker types.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".