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
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>
fn or<M>(self, other: M) -> impl Matcher<State, Request>
Provide an alternative matcher to match if the current one does not match.
Trait Implementations§
§impl<State, Request> Matcher<State, Request> for Box<dyn Matcher<State, Request>>
impl<State, Request> Matcher<State, Request> for Box<dyn Matcher<State, Request>>
§fn matches(
&self,
ext: Option<&mut Extensions>,
ctx: &Context<State>,
req: &Request,
) -> bool
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>
fn or<M>(self, other: M) -> impl Matcher<State, Request>
Provide an alternative matcher to match if the current one does not match.