Struct gotham::router::non_match::RouteNonMatch [−][src]
The error type used for a non-matching route, as returned by RouteMatcher::is_match
. Multiple
values of this type can be combined by matchers that are wrapping other matchers, using the
intersection
/ union
methods. The data within is used by the Router
to create a
Response
when no routes were successfully matched.
#[derive(Clone)] struct MyRouteMatcher; impl RouteMatcher for MyRouteMatcher { fn is_match(&self, state: &State) -> Result<(), RouteNonMatch> { match state.borrow::<Method>() { &Method::GET => Ok(()), _ => Err( RouteNonMatch::new(StatusCode::METHOD_NOT_ALLOWED) .with_allow_list(&[Method::GET]), ), } } }
Implementations
impl RouteNonMatch
[src]
pub fn new(status: StatusCode) -> RouteNonMatch
[src]
Creates a new RouteNonMatch
value with the given HTTP status.
pub fn with_allow_list(self, allow: &[Method]) -> RouteNonMatch
[src]
Adds an allow list to a RouteNonMatch
. Typically this is used with a 405 Method Not Allowed
status code, so the Router
can accurately populate the Allow
header in the
response. It must be populated by any RouteMatcher
which restricts the HTTP method.
pub fn intersection(self, other: RouteNonMatch) -> RouteNonMatch
[src]
Takes the intersection of two RouteNonMatch
values, producing a single result. This is
intended for use in cases where two RouteMatcher
instances with a logical AND
connection have both indicated a non-match, and their results need to be aggregated.
This is typically for Gotham internal use, but may be useful for implementors of matchers
which wrap other RouteMatcher
instances. See the AndRouteMatcher
implementation (in
gotham::router::route::matcher::and
) for an example.
pub fn union(self, other: RouteNonMatch) -> RouteNonMatch
[src]
Takes the union of two RouteNonMatch
values, producing a single result. This is intended
for use in cases where two RouteMatcher
instances with a logical OR connection have
both indicated a non-match, and their results need to be aggregated.
This is typically for Gotham internal use, but may be useful for implementors of matchers
which wrap other RouteMatcher
instances. See the Node::select_route
implementation (in
gotham::router::tree
) for an example.
Trait Implementations
impl Clone for RouteNonMatch
[src]
fn clone(&self) -> RouteNonMatch
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for RouteNonMatch
impl Send for RouteNonMatch
impl Sync for RouteNonMatch
impl Unpin for RouteNonMatch
impl UnwindSafe for RouteNonMatch
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,