Skip to main content

Redactable

Trait Redactable 

Source
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§

Source

fn redact(self) -> Self

Redacts the value using policy-bound redaction.

This consumes self and returns a redacted copy.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Redactable for Value

Source§

impl<K, V, S> Redactable for HashMap<K, V, S>
where K: Hash + Eq, V: Redactable, S: BuildHasher + Clone,

Source§

impl<K: Ord, V: Redactable> Redactable for BTreeMap<K, V>

Source§

impl<T0, T1, T2, T3> Redactable for (T0, T1, T2, T3)
where T0: Redactable, T1: Redactable, T2: Redactable, T3: Redactable,

Source§

impl<T0, T1, T2> Redactable for (T0, T1, T2)
where T0: Redactable, T1: Redactable, T2: Redactable,

Source§

impl<T0, T1> Redactable for (T0, T1)
where T0: Redactable, T1: Redactable,

Source§

impl<T0> Redactable for (T0,)
where T0: Redactable,

Source§

impl<T, S> Redactable for HashSet<T, S>
where T: Redactable + Hash + Eq, S: BuildHasher + Clone,

Source§

impl<T: Redactable + Clone> Redactable for Arc<T>

Source§

impl<T: Redactable + Clone> Redactable for Rc<T>

Source§

impl<T: Redactable + Copy> Redactable for Cell<T>

Source§

impl<T: Redactable + Ord> Redactable for BTreeSet<T>

Source§

impl<T: Redactable, E: Redactable> Redactable for Result<T, E>

Source§

impl<T: Redactable, const N: usize> Redactable for [T; N]

Source§

impl<T: Redactable> Redactable for Box<T>

Source§

impl<T: Redactable> Redactable for Mutex<T>

Source§

impl<T: Redactable> Redactable for Option<T>

Source§

impl<T: Redactable> Redactable for RefCell<T>

Source§

impl<T: Redactable> Redactable for RwLock<T>

Source§

impl<T: Redactable> Redactable for Vec<T>

Source§

impl<T: Redactable> Redactable for VecDeque<T>

Implementors§