Skip to main content

RegexScanner

Struct RegexScanner 

Source
pub struct RegexScanner { /* private fields */ }
Expand description

Redacts matches of caller-supplied patterns, RoundTrip by default.

Implementations§

Source§

impl RegexScanner

Source

pub const ID: ScannerId

This scanner’s id.

Source

pub fn new(rules: Vec<RegexRule>) -> Self

Build a scanner from compiled rules. Direction defaults to Direction::Input, policy to RestorePolicy::RoundTrip.

Source

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.

Source

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).

Source

pub fn with_policy(self, policy: RestorePolicy) -> Self

Override the restore policy. RoundTrip tokenizes and a paired RestoreScanner rehydrates on output; OneWay redacts permanently.

Source

pub fn policy(&self) -> RestorePolicy

This scanner’s restore policy.

Source

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

Source§

fn clone(&self) -> RegexScanner

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RegexScanner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Scanner for RegexScanner

Source§

fn id(&self) -> ScannerId

Stable identifier (e.g. native:pii).
Source§

fn direction(&self) -> Direction

Which path this scanner runs on.
Source§

fn disposition(&self) -> Disposition

Whether this scanner may block, or only transforms.
Source§

fn scan<'a>(&self, text: &'a str, ctx: &mut ScanCtx) -> ScanResult<'a>

Inspect/transform text. The borrowed Verdict::text lets a pure detector return the input with zero allocation. Read more
Source§

fn max_input_inflation_ratio(&self) -> f64

Token-inflation bound for an admission estimate (sentinels grow the request). Default 1.0.
Source§

fn hold_back(&self) -> HoldBack

How much trailing text a streaming OUTPUT runner must hold back for this scanner. Default HoldBack::TokenBoundary — most patterns are token-bounded. A full-text scanner overrides to HoldBack::WholeStream. Read more
Source§

fn stream_patterns(&self) -> Vec<String>

The regex patterns this scanner redacts (or blocks on) when it runs on the OUTPUT path — the shapes the streaming runner’s hold-back DFA must recognise so a match forming across a chunk boundary is never half- emitted. Default empty: a scanner that never redacts streamed output (a pure restore scanner, an input-only scanner) contributes nothing; the runner still holds back live vault sentinels for restore independently. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V