Trait Matcher
pub trait Matcher<Request>:
Send
+ Sync
+ 'static {
// Required method
fn matches(&self, ext: Option<&mut Extensions>, req: &Request) -> bool;
// Provided methods
fn or<M>(self, other: M) -> impl Matcher<Request>
where Self: Sized,
M: Matcher<Request> { ... }
fn and<M>(self, other: M) -> impl Matcher<Request>
where Self: Sized,
M: Matcher<Request> { ... }
fn not(self) -> impl Matcher<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>, req: &Request) -> bool
fn matches(&self, ext: Option<&mut Extensions>, 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<Request>
fn or<M>(self, other: M) -> impl Matcher<Request>
Provide an alternative matcher to match if the current one does not match.
Trait Implementations§
§impl<Request> Matcher<Request> for Box<dyn Matcher<Request>>where
Request: Send + 'static,
impl<Request> Matcher<Request> for Box<dyn Matcher<Request>>where
Request: Send + 'static,
§fn matches(&self, ext: Option<&mut Extensions>, req: &Request) -> bool
fn matches(&self, ext: Option<&mut Extensions>, req: &Request) -> bool
returns true on a match, false otherwise Read more
§fn or<M>(self, other: M) -> impl Matcher<Request>
fn or<M>(self, other: M) -> impl Matcher<Request>
Provide an alternative matcher to match if the current one does not match.
Implementations on Foreign Types§
§impl<Request, T> Matcher<Request> for &'static Twhere
T: Matcher<Request>,
impl<Request, T> Matcher<Request> for &'static Twhere
T: Matcher<Request>,
Implementors§
impl<A, B, C, D, E, F, G, H, I, Request> Matcher<Request> for Either9<A, B, C, D, E, F, G, H, I>
impl<A, B, C, D, E, F, G, H, Request> Matcher<Request> for Either8<A, B, C, D, E, F, G, H>
impl<A, B, C, D, E, F, G, Request> Matcher<Request> for Either7<A, B, C, D, E, F, G>
impl<A, B, C, D, E, F, Request> Matcher<Request> for Either6<A, B, C, D, E, F>
impl<A, B, C, D, E, Request> Matcher<Request> for Either5<A, B, C, D, E>
impl<A, B, C, D, Request> Matcher<Request> for Either4<A, B, C, D>
impl<A, B, C, Request> Matcher<Request> for Either3<A, B, C>
impl<A, B, Request> Matcher<Request> for Either<A, B>
impl<Body> Matcher<Request<Body>> for HttpMatcherKind<Body>where
Body: Send + 'static,
impl<Body> Matcher<Request<Body>> for DomainMatcher
impl<Body> Matcher<Request<Body>> for HeaderMatcher
impl<Body> Matcher<Request<Body>> for HttpMatcher<Body>where
Body: Send + 'static,
impl<Body> Matcher<Request<Body>> for MethodMatcher
impl<Body> Matcher<Request<Body>> for PathMatcher
impl<Body> Matcher<Request<Body>> for SubdomainTrieMatcher
impl<Body> Matcher<Request<Body>> for UriMatcher
impl<Body> Matcher<Request<Body>> for VersionMatcher
impl<Body> Matcher<Request<Body>> for WebSocketMatcherwhere
Body: Send + 'static,
impl<Body> Matcher<Request<Body>> for IpNetMatcher
Available on crate feature
http only.impl<Body> Matcher<Request<Body>> for LoopbackMatcher
Available on crate feature
http only.impl<Body> Matcher<Request<Body>> for PortMatcher
Available on crate feature
http only.impl<Body> Matcher<Request<Body>> for PrivateIpNetMatcher
Available on crate feature
http only.impl<Body> Matcher<Request<Body>> for SocketAddressMatcher
Available on crate feature
http only.impl<Body> Matcher<Request<Body>> for SocketMatcher<Request<Body>>where
Body: 'static,
Available on crate feature
http only.