Skip to main content

evaluate_condition

Function evaluate_condition 

Source
pub fn evaluate_condition<C: RuleEvaluationContext + ?Sized>(
    condition: &RuleCondition,
    ctx: &C,
) -> bool
Expand description

Evaluate a single RuleCondition against ctx. Pure function; no I/O, no allocation outside the regex case (see below).

RegexMatch compiles its pattern on every call. Callers that evaluate the same regex thousands of times should hoist the compile out of the rule by pre-computing a [RuleCondition::Set Membership] or wrapping a custom RuleCondition::Opaque extension that caches its own compiled regex.

Opaque extension conditions delegate via RuleConditionExt::evaluate_opaque; the trait passes a &dyn Any reference so extensions can downcast to whatever context type they require. The RuleEvaluationContext is passed via the Any payload by reference so an extension that needs the standard context can downcast to &C.