rskit_logging/masking/masker.rs
1//! Masker abstraction for redacting sensitive values in log output.
2
3use std::borrow::Cow;
4
5/// Trait for masking sensitive values in log output.
6///
7/// Implement this trait to provide custom masking rules.
8pub trait Masker: Send + Sync {
9 /// Mask a value based on its field key and content.
10 ///
11 /// Returns the original value unchanged if no masking is needed,
12 /// or a masked version if the value contains sensitive data.
13 fn mask_value<'v>(&self, key: &str, value: &'v str) -> Cow<'v, str>;
14
15 /// Mask sensitive data in a formatted log output string.
16 ///
17 /// Applies both field-name and value-pattern masking to a complete log line.
18 /// Used by [`MaskingMakeWriter`](super::MaskingMakeWriter) to mask output before writing to the underlying writer.
19 fn mask_output<'v>(&self, line: &'v str) -> Cow<'v, str>;
20}