Trait rama::matcher::Matcher

pub trait Matcher<State, Request>:
    Send
    + Sync
    + 'static {
    // Required method
    fn matches(
        &self,
        ext: Option<&mut Extensions>,
        ctx: &Context<State>,
        req: &Request,
    ) -> bool;

    // Provided methods
    fn or<M>(self, other: M) -> impl Matcher<State, Request>
       where Self: Sized,
             M: Matcher<State, Request> { ... }
    fn and<M>(self, other: M) -> impl Matcher<State, Request>
       where Self: Sized,
             M: Matcher<State, Request> { ... }
    fn not(self) -> impl Matcher<State, Request>
       where Self: Sized { ... }
}
Expand description

A condition to decide whether Request within the given Context matches for router or other middleware purposes.

Required Methods§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

returns true on a match, false otherwise

ext is None in case the callee is not interested in collecting potential match metadata gathered during the matching process. An example of this path parameters for an http Uri matcher.

Provided Methods§

fn or<M>(self, other: M) -> impl Matcher<State, Request>
where Self: Sized, M: Matcher<State, Request>,

Provide an alternative matcher to match if the current one does not match.

fn and<M>(self, other: M) -> impl Matcher<State, Request>
where Self: Sized, M: Matcher<State, Request>,

Add another condition to match on top of the current one.

fn not(self) -> impl Matcher<State, Request>
where Self: Sized,

Negate the current condition.

Trait Implementations§

§

impl<State, Request> Matcher<State, Request> for Box<dyn Matcher<State, Request>>
where State: Clone + Send + Sync + 'static, Request: Send + 'static,

§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

returns true on a match, false otherwise Read more
§

fn or<M>(self, other: M) -> impl Matcher<State, Request>
where Self: Sized, M: Matcher<State, Request>,

Provide an alternative matcher to match if the current one does not match.
§

fn and<M>(self, other: M) -> impl Matcher<State, Request>
where Self: Sized, M: Matcher<State, Request>,

Add another condition to match on top of the current one.
§

fn not(self) -> impl Matcher<State, Request>
where Self: Sized,

Negate the current condition.

Implementations on Foreign Types§

§

impl<State, Request> Matcher<State, Request> for bool

§

fn matches( &self, _: Option<&mut Extensions>, _: &Context<State>, _: &Request, ) -> bool

§

impl<State, Request> Matcher<State, Request> for Box<dyn Matcher<State, Request>>
where State: Clone + Send + Sync + 'static, Request: Send + 'static,

§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

§

impl<State, Request, T> Matcher<State, Request> for Option<T>
where T: Matcher<State, Request>,

§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

§

impl<State, Request, T> Matcher<State, Request> for &'static T
where T: Matcher<State, Request>,

§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

§

impl<State, Request, T> Matcher<State, Request> for Box<T>
where T: Matcher<State, Request>,

§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

§

impl<State, Request, T> Matcher<State, Request> for Arc<T>
where T: Matcher<State, Request>,

§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request, ) -> bool

Implementors§

§

impl<A, B, C, D, E, F, G, H, I, State, Request> Matcher<State, Request> for Either9<A, B, C, D, E, F, G, H, I>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, D: Matcher<State, Request>, E: Matcher<State, Request>, F: Matcher<State, Request>, G: Matcher<State, Request>, H: Matcher<State, Request>, I: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, C, D, E, F, G, H, State, Request> Matcher<State, Request> for Either8<A, B, C, D, E, F, G, H>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, D: Matcher<State, Request>, E: Matcher<State, Request>, F: Matcher<State, Request>, G: Matcher<State, Request>, H: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, C, D, E, F, G, State, Request> Matcher<State, Request> for Either7<A, B, C, D, E, F, G>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, D: Matcher<State, Request>, E: Matcher<State, Request>, F: Matcher<State, Request>, G: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, C, D, E, F, State, Request> Matcher<State, Request> for Either6<A, B, C, D, E, F>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, D: Matcher<State, Request>, E: Matcher<State, Request>, F: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, C, D, E, State, Request> Matcher<State, Request> for Either5<A, B, C, D, E>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, D: Matcher<State, Request>, E: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, C, D, State, Request> Matcher<State, Request> for Either4<A, B, C, D>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, D: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, C, State, Request> Matcher<State, Request> for Either3<A, B, C>
where A: Matcher<State, Request>, B: Matcher<State, Request>, C: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<A, B, State, Request> Matcher<State, Request> for Either<A, B>
where A: Matcher<State, Request>, B: Matcher<State, Request>, Request: Send + 'static, State: Clone + Send + Sync + 'static,

§

impl<State, Body> Matcher<State, Request<Body>> for HttpMatcherKind<State, Body>
where State: Clone + Send + Sync + 'static, Body: Send + 'static,

§

impl<State, Body> Matcher<State, Request<Body>> for DomainMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for HeaderMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for HttpMatcher<State, Body>
where State: Clone + Send + Sync + 'static, Body: Send + 'static,

§

impl<State, Body> Matcher<State, Request<Body>> for MethodMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for PathMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for UriMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for VersionMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for IpNetMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for LoopbackMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for PortMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for PrivateIpNetMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for SocketAddressMatcher

§

impl<State, Body> Matcher<State, Request<Body>> for SocketMatcher<State, Request<Body>>
where State: 'static, Body: 'static,

§

impl<State, Request, P, T> Matcher<State, Request> for ExtensionMatcher<P, T>
where State: Clone + Send + Sync + 'static, Request: Send + 'static, T: Clone + Send + Sync + 'static, P: ExtensionPredicate<T>,

§

impl<State, Request, T1> Matcher<State, Request> for And<(T1,)>
where T1: Matcher<State, Request>,

§

impl<State, Request, T1> Matcher<State, Request> for Or<(T1,)>
where T1: Matcher<State, Request>,

§

impl<State, Request, T1, T2> Matcher<State, Request> for And<(T1, T2)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>,

§

impl<State, Request, T1, T2> Matcher<State, Request> for Or<(T1, T2)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3> Matcher<State, Request> for And<(T1, T2, T3)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3> Matcher<State, Request> for Or<(T1, T2, T3)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4> Matcher<State, Request> for And<(T1, T2, T3, T4)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4> Matcher<State, Request> for Or<(T1, T2, T3, T4)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5> Matcher<State, Request> for And<(T1, T2, T3, T4, T5)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6, T7)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6, T7)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6, T7, T8)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6, T7, T8)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>, T10: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>, T10: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>, T10: Matcher<State, Request>, T11: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>, T10: Matcher<State, Request>, T11: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Matcher<State, Request> for And<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>, T10: Matcher<State, Request>, T11: Matcher<State, Request>, T12: Matcher<State, Request>,

§

impl<State, Request, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Matcher<State, Request> for Or<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>
where T1: Matcher<State, Request>, T2: Matcher<State, Request>, T3: Matcher<State, Request>, T4: Matcher<State, Request>, T5: Matcher<State, Request>, T6: Matcher<State, Request>, T7: Matcher<State, Request>, T8: Matcher<State, Request>, T9: Matcher<State, Request>, T10: Matcher<State, Request>, T11: Matcher<State, Request>, T12: Matcher<State, Request>,

§

impl<State, Request, T> Matcher<State, Request> for Not<T>
where T: Matcher<State, Request>,

§

impl<State, Socket> Matcher<State, Socket> for IpNetMatcher
where Socket: Socket,

§

impl<State, Socket> Matcher<State, Socket> for LoopbackMatcher
where Socket: Socket,

§

impl<State, Socket> Matcher<State, Socket> for PortMatcher
where Socket: Socket,

§

impl<State, Socket> Matcher<State, Socket> for PrivateIpNetMatcher
where Socket: Socket,

§

impl<State, Socket> Matcher<State, Socket> for SocketAddressMatcher
where Socket: Socket,

§

impl<State, Socket> Matcher<State, Socket> for SocketMatcher<State, Socket>
where Socket: Socket, State: 'static,