pub struct RegexScanner { /* private fields */ }Expand description
Redacts matches of caller-supplied patterns, RoundTrip by default.
Implementations§
Source§impl RegexScanner
impl RegexScanner
Sourcepub fn new(rules: Vec<RegexRule>) -> Self
pub fn new(rules: Vec<RegexRule>) -> Self
Build a scanner from compiled rules. Direction defaults to
Direction::Input, policy to RestorePolicy::RoundTrip.
Sourcepub fn from_patterns<'a>(
patterns: impl IntoIterator<Item = (&'a str, &'a str)>,
) -> (Self, Vec<(String, Error)>)
pub fn from_patterns<'a>( patterns: impl IntoIterator<Item = (&'a str, &'a str)>, ) -> (Self, Vec<(String, Error)>)
Build a scanner from (pattern, label) pairs, compiling each. Patterns
that fail to compile are skipped and returned alongside the scanner so the
caller can surface a configuration error rather than silently dropping a
rule.
Sourcepub fn with_direction(self, direction: Direction) -> Self
pub fn with_direction(self, direction: Direction) -> Self
Override the direction this scanner runs on (input, output, or — by registering the scanner in both directions — both).
Sourcepub fn with_policy(self, policy: RestorePolicy) -> Self
pub fn with_policy(self, policy: RestorePolicy) -> Self
Override the restore policy. RoundTrip tokenizes and a paired
RestoreScanner rehydrates on output;
OneWay redacts permanently.
Sourcepub fn policy(&self) -> RestorePolicy
pub fn policy(&self) -> RestorePolicy
This scanner’s restore policy.
Sourcepub fn labels(&self) -> impl Iterator<Item = &str>
pub fn labels(&self) -> impl Iterator<Item = &str>
The entity labels this scanner interns under — the set a
RestoreScanner must own to rehydrate
its RoundTrip redactions.
Trait Implementations§
Source§impl Clone for RegexScanner
impl Clone for RegexScanner
Source§fn clone(&self) -> RegexScanner
fn clone(&self) -> RegexScanner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RegexScanner
impl Debug for RegexScanner
Source§impl Scanner for RegexScanner
impl Scanner for RegexScanner
Source§fn disposition(&self) -> Disposition
fn disposition(&self) -> Disposition
Source§fn scan<'a>(&self, text: &'a str, ctx: &mut ScanCtx) -> ScanResult<'a>
fn scan<'a>(&self, text: &'a str, ctx: &mut ScanCtx) -> ScanResult<'a>
text. The borrowed Verdict::text lets a pure
detector return the input with zero allocation. Read moreSource§fn max_input_inflation_ratio(&self) -> f64
fn max_input_inflation_ratio(&self) -> f64
1.0.Source§fn hold_back(&self) -> HoldBack
fn hold_back(&self) -> HoldBack
HoldBack::TokenBoundary — most patterns are
token-bounded. A full-text scanner overrides to HoldBack::WholeStream. Read moreSource§fn stream_patterns(&self) -> Vec<String>
fn stream_patterns(&self) -> Vec<String>
Auto Trait Implementations§
impl Freeze for RegexScanner
impl RefUnwindSafe for RegexScanner
impl Send for RegexScanner
impl Sync for RegexScanner
impl Unpin for RegexScanner
impl UnsafeUnpin for RegexScanner
impl UnwindSafe for RegexScanner
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more