Trait netstack3_base::Matcher

source ·
pub trait Matcher<T> {
    // Required method
    fn matches(&self, actual: &T) -> bool;

    // Provided method
    fn required_matches(&self, actual: Option<&T>) -> bool { ... }
}
Expand description

Common pattern to define a matcher for a metadata input T.

Used in matching engines like filtering and routing rules.

Required Methods§

source

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

Returns whether the provided value matches.

Provided Methods§

source

fn required_matches(&self, actual: Option<&T>) -> bool

Returns whether the provided value is set and matches.

Implementations on Foreign Types§

source§

impl<T, O> Matcher<T> for Option<O>
where O: Matcher<T>,

Implement Matcher for optional matchers, so that if a matcher is left unspecified, it matches all inputs by default.

source§

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

source§

fn required_matches(&self, actual: Option<&T>) -> bool

Implementors§