logo
pub struct Router<T, U = ()> { /* private fields */ }
Expand description

Resource router.

It matches a routing resource to an ordered list of routes. Each is defined by a single ResourceDef and contains two types of custom data:

  1. The route value, of the generic type T.
  2. Some context data, of the generic type U, which is only provided to the check function in recognize_fn. This parameter defaults to () and can be omitted if not required.

Implementations

Constructs new RouterBuilder with empty route list.

Finds the value in the router that matches a given routing resource.

The match result, including the captured dynamic segments, in the resource.

Same as recognize but returns a mutable reference to the matched value.

Finds the value in the router that matches a given routing resource and passes an additional predicate check using context data.

Similar to recognize. However, before accepting the route as matched, the check closure is executed, passing the resource and each route’s context data. If the closure returns true then the match result is stored into resource and a reference to the matched value is returned.

Same as recognize_fn but returns a mutable reference to the matched value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more