Matcher

Trait Matcher 

Source
pub trait Matcher<T: Matchable> {
    // Required methods
    fn matches(&self, value: &T) -> bool;
    fn mode(&self) -> ConditionMode;
}
Expand description

Core trait for any type that can match against a value.

This is the primary interface users interact with. Both RuleMatcher and JsonMatcher implement this trait.

§Example

use condition_matcher::{Matcher, MatcherBuilder};

let matcher = MatcherBuilder::<i32>::new()
    .value_equals(42)
    .build();

assert!(matcher.matches(&42));
assert!(!matcher.matches(&41));

Required Methods§

Source

fn matches(&self, value: &T) -> bool

Check if this matcher matches the given value.

Source

fn mode(&self) -> ConditionMode

Get the logical combination mode (AND, OR, XOR).

Implementations on Foreign Types§

Source§

impl<T: Matchable, M: Matcher<T>> Matcher<T> for &M

Source§

fn matches(&self, value: &T) -> bool

Source§

fn mode(&self) -> ConditionMode

Implementors§

Source§

impl<'a, T: Matchable + 'static> Matcher<T> for RuleMatcher<'a, T>