Skip to main content

wyrd_runtime/
redaction.rs

1//! Redaction sink shell.
2
3use wyrd_spec::redaction::{Redactable, RedactionPolicy};
4
5/// Redaction sink installation plan.
6#[derive(Debug, Clone, Default, PartialEq, Eq)]
7pub struct RedactionSinkPlan {
8    /// Number of field-pattern rules configured on the policy.
9    pub field_pattern_count: usize,
10    /// Number of JSON-path rules configured on the policy.
11    pub json_path_count: usize,
12}
13
14/// Prepare redaction sink wiring for the supplied policy.
15#[must_use]
16pub fn sink(policy: &RedactionPolicy) -> RedactionSinkPlan {
17    RedactionSinkPlan {
18        field_pattern_count: policy.field_patterns.len(),
19        json_path_count: policy.json_paths.len(),
20    }
21}
22
23/// Apply redaction to a value.
24pub fn redact<T: Redactable>(value: &mut T, policy: &RedactionPolicy) {
25    value.redact(policy);
26}