pub struct TerminalRedactionRule {
pub name: String,
pub pattern: String,
pub replacement: String,
}Expand description
One named, literal text replacement rule.
The name is metadata only. Matching uses str::replace, is
case-sensitive, and ignores a rule whose pattern is empty.
§Examples
use ailloli_ui_terminal_core::TerminalRedactionRule;
let rule = TerminalRedactionRule::exact("account", "alice@example.com");
assert_eq!(rule.name, "account");
assert_eq!(rule.pattern, "alice@example.com");
assert_eq!(rule.replacement, "[redacted]");Fields§
§name: StringInformational rule name; it does not affect matching.
pattern: StringCase-sensitive literal pattern; an empty pattern is ignored.
replacement: StringText inserted for every match; it may be empty.
Implementations§
Source§impl TerminalRedactionRule
impl TerminalRedactionRule
Sourcepub fn exact(name: impl Into<String>, pattern: impl Into<String>) -> Self
pub fn exact(name: impl Into<String>, pattern: impl Into<String>) -> Self
Creates a literal rule whose replacement is "[redacted]".
name and pattern are stored without validation. In particular, an
empty pattern is accepted but later ignored by the policy.
§Examples
use ailloli_ui_terminal_core::{TerminalRedactionPolicy, TerminalRedactionRule};
let mut policy = TerminalRedactionPolicy::default();
policy.rules.push(TerminalRedactionRule::exact("user", "alice"));
assert_eq!(policy.redact_text("alice and Alice"), "[redacted] and Alice");Trait Implementations§
Source§impl Clone for TerminalRedactionRule
impl Clone for TerminalRedactionRule
Source§fn clone(&self) -> TerminalRedactionRule
fn clone(&self) -> TerminalRedactionRule
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TerminalRedactionRule
impl Debug for TerminalRedactionRule
Source§impl<'de> Deserialize<'de> for TerminalRedactionRule
impl<'de> Deserialize<'de> for TerminalRedactionRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for TerminalRedactionRule
impl PartialEq for TerminalRedactionRule
Source§impl Serialize for TerminalRedactionRule
impl Serialize for TerminalRedactionRule
impl Eq for TerminalRedactionRule
impl StructuralPartialEq for TerminalRedactionRule
Auto Trait Implementations§
impl Freeze for TerminalRedactionRule
impl RefUnwindSafe for TerminalRedactionRule
impl Send for TerminalRedactionRule
impl Sync for TerminalRedactionRule
impl Unpin for TerminalRedactionRule
impl UnwindSafe for TerminalRedactionRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more