[][src]Trait usher::matcher::Matcher

pub trait Matcher: Send + Sync {
    fn is_match(&self, segment: &str) -> bool;

    fn capture<'a>(&'a self, _segment: &str) -> Option<Capture<'a>> { ... }
}

Matching trait to enable generic route matching algorithms.

This trait backs the main tree, enabling custom segment matching based on the needs of the end developer. In many cases it's wasteful to check for things like RegEx, especially when all routes will only be static (as an example).

Required methods

fn is_match(&self, segment: &str) -> bool

Determines whether an incoming segment is a match for a base segment.

Loading content...

Provided methods

fn capture<'a>(&'a self, _segment: &str) -> Option<Capture<'a>>

Retrieves a potential capture from a segment.

Loading content...

Implementors

impl Matcher for DynamicMatcher[src]

fn capture<'a>(&'a self, segment: &str) -> Option<Capture<'a>>[src]

Determines if there is a capture for the incoming segment.

fn is_match(&self, _segment: &str) -> bool[src]

Determines if this matcher matches the incoming segment.

impl Matcher for StaticMatcher[src]

fn is_match(&self, segment: &str) -> bool[src]

Compares an incoming segment against a literal base segment.

fn capture<'a>(&'a self, _segment: &str) -> Option<Capture<'a>>[src]

impl<F> Matcher for F where
    F: Fn(&str) -> bool + Send + Sync
[src]

Blanket implementation of Matcher for pure functions.

Pure functions are assumed to not have a capture group, as there's no way to directly name them at this point (unless derived from the input).

fn is_match(&self, segment: &str) -> bool[src]

Determines whether an incoming segment is a match for a base segment.

fn capture<'a>(&'a self, _segment: &str) -> Option<Capture<'a>>[src]

Loading content...