Skip to main content

RegexEngine

Struct RegexEngine 

Source
pub struct RegexEngine<N: Normalizer = ProductionNormalizer, P: Prefilter = PrefixPrefilter> { /* private fields */ }
Expand description

Production rule engine: pluggable normalizer + prefilter + RegexSet DFA.

Default type parameters give zero-cost production behavior via monomorphization. Tests can substitute IdentityNormalizer and/or NullPrefilter for isolation.

§Examples

use guardrail::engine::*;
let rules = vec![]; // load from config
// Production (default):
let engine = RegexEngine::new(rules.clone())?;
// Testing (no normalization, no prefilter):
let engine = RegexEngine::with_plugins(rules, IdentityNormalizer, NullPrefilter)?;

Implementations§

Source§

impl RegexEngine

Default constructor – production configuration.

Source

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

Create an engine with ProductionNormalizer + PrefixPrefilter.

§Errors

Returns an error if any regex pattern is invalid or the compiled DFA exceeds the 100MB size limit.

Source§

impl<N: Normalizer, P: Prefilter> RegexEngine<N, P>

Source

pub fn with_plugins( rules: Vec<Rule>, normalizer: N, prefilter: P, ) -> Result<Self>

Create an engine with custom normalizer and prefilter.

§Errors

Returns an error if any regex pattern is invalid.

Trait Implementations§

Source§

impl<N: Normalizer + Debug, P: Prefilter + Debug> Debug for RegexEngine<N, P>

Source§

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

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

impl<N: Normalizer, P: Prefilter> RuleEngine for RegexEngine<N, P>

Source§

fn check(&self, command: &str) -> Decision

Source§

fn rules(&self) -> &[Rule]

Source§

fn rule_count(&self) -> usize

Auto Trait Implementations§

§

impl<N, P> Freeze for RegexEngine<N, P>
where N: Freeze, P: Freeze,

§

impl<N, P> RefUnwindSafe for RegexEngine<N, P>

§

impl<N, P> Send for RegexEngine<N, P>

§

impl<N, P> Sync for RegexEngine<N, P>

§

impl<N, P> Unpin for RegexEngine<N, P>
where N: Unpin, P: Unpin,

§

impl<N, P> UnsafeUnpin for RegexEngine<N, P>
where N: UnsafeUnpin, P: UnsafeUnpin,

§

impl<N, P> UnwindSafe for RegexEngine<N, P>
where N: UnwindSafe, P: UnwindSafe,

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