[−][src]Struct trout::node::Node
The building block of a routing tree.
Each node can contain handlers, which will be used when this is the node reached at the end of the path, as well as children, which will be traversed otherwise.
Implementations
impl<P: 'static, R: Request + 'static, T: 'static, C: 'static> Node<P, R, T, C>
[src]
pub fn new() -> Self
[src]
Construct a new Node
pub fn with_handler(
self,
method: &'static str,
handler: impl Fn(P, C, R) -> T + 'static + Send + Sync
) -> Self
[src]
self,
method: &'static str,
handler: impl Fn(P, C, R) -> T + 'static + Send + Sync
) -> Self
Add a method handler to this node.
For use with async, you may wish to use [with_handler_async
] instead.
pub fn with_child(self, path: &'static str, child: Node<P, R, T, C>) -> Self
[src]
Add a child node with a constant path. The path argument must end at the end of a path segment, but can contain slashes in order to skip levels
Example
trout::Node::new() .with_child("items", other_node);
pub fn with_child_str<P2: TupleAdd<P, String> + 'static>(
self,
child: Node<P2, R, T, C>
) -> Self
[src]
self,
child: Node<P2, R, T, C>
) -> Self
Add a child node with a dynamic path segment (string form)
Example
trout::Node::new() .with_child_str(other_node)
pub fn with_child_parse<A: FromStr + Send + Sync + 'static, P2: TupleAdd<P, A> + 'static>(
self,
child: Node<P2, R, T, C>
) -> Self
[src]
self,
child: Node<P2, R, T, C>
) -> Self
Add a child node with a dynamic path segment (parsing form)
Example
trout::Node::new() .with_child_parse::<i32, _>(other_node)
impl<P: 'static, R: Request + 'static, TR: 'static, C: 'static> Node<P, R, Pin<Box<dyn Future<Output = TR> + Send>>, C>
[src]
pub fn with_handler_async<F: Future<Output = TR> + Send + 'static>(
self,
method: &'static str,
handler: impl Fn(P, C, R) -> F + Send + Sync + 'static
) -> Self
[src]
self,
method: &'static str,
handler: impl Fn(P, C, R) -> F + Send + Sync + 'static
) -> Self
Convenience method for handlers returning Pin<Box<Future>>
s
impl<R: Request + 'static, T: 'static, C: 'static> Node<(), R, T, C>
[src]
pub fn route(&self, req: R, ctx: C) -> Result<T, RoutingFailure>
[src]
Perform routing for a request
Trait Implementations
Auto Trait Implementations
impl<P, R, T, C> !RefUnwindSafe for Node<P, R, T, C>
impl<P, R, T, C> Send for Node<P, R, T, C>
impl<P, R, T, C> Sync for Node<P, R, T, C>
impl<P, R, T, C> Unpin for Node<P, R, T, C>
impl<P, R, T, C> !UnwindSafe for Node<P, R, T, C>
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,