[][src]Trait usher::parser::Parser

pub trait Parser: Send + Sync {
    fn parse(&self, segment: &str) -> Option<Box<dyn Matcher>>;
}

Parsing trait to enable conversion from literals into matchers.

This is used to run through a cascading parsing flow to enable custom matchers being implemented. This trait enables all segment matching to be determined at creation time to avoid any costs at routing time.

Required methods

fn parse(&self, segment: &str) -> Option<Box<dyn Matcher>>

Attempts to parse a Matcher out of a segment.

Loading content...

Implementors

impl Parser for DynamicParser[src]

fn parse(&self, segment: &str) -> Option<Box<dyn Matcher>>[src]

Parses out a dynamic segment based on the :.+ syntax.

If you wish to use a custom syntax, you can construct a custom Parser implementation which constructs a DynamicMatcher instance.

impl Parser for StaticParser[src]

Parser implementation for the static matcher.

fn parse(&self, segment: &str) -> Option<Box<dyn Matcher>>[src]

Parses out a static matcher from a segment literal.

Note that although this returns a result, it will never fail as every string literal can be treated as a static matcher.

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

Blanket implementation of Parser for pure functions.

fn parse(&self, segment: &str) -> Option<Box<dyn Matcher>>[src]

Attempts to parse a Matcher out of a segment.

Loading content...