pub struct Redactor { /* private fields */ }Expand description
A fused-alternation redactor: one regex, one pass, N patterns.
See the crate-level docs for the performance model.
Implementations§
Source§impl Redactor
impl Redactor
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Construct a redactor with no patterns and the default
marker. Add patterns via Self::with_pattern.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Construct a redactor pre-loaded with every built-in pattern: credit card, JWT, OAuth bearer, email, IPv4, AWS key.
All six patterns are fused into a single alternation regex
at process start-up (via LazyLock). Subsequent calls to
this constructor clone the cached Regex — construction is
O(1) past the first call.
Sourcepub fn with_pattern(self, pattern: &str) -> Result<Self, Error>
pub fn with_pattern(self, pattern: &str) -> Result<Self, Error>
Append a custom regex pattern.
The pattern is validated in isolation before being fused into the combined alternation, so a compile error surfaces the specific bad pattern rather than the fused string.
§Errors
Returns regex::Error if the pattern fails to compile.
Sourcepub fn marker(self, marker: impl Into<String>) -> Self
pub fn marker(self, marker: impl Into<String>) -> Self
Override the replacement marker (default: "[REDACTED]").
Sourcepub fn scrub(&self, log: Log) -> Log
pub fn scrub(&self, log: Log) -> Log
Scrub a record in-place. Returns the (possibly modified) record for fluent chaining.