Struct trout::node::Node

source · []
pub struct Node<P, R: Request, T, C> { /* private fields */ }
Expand description

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

Construct a new Node

Add a method handler to this node. For use with async, you may wish to use [with_handler_async] instead.

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);

Add a child node with a dynamic path segment (string form)

Example
trout::Node::new()
    .with_child_str(other_node)

Add a child node with a dynamic path segment (parsing form)

Example
trout::Node::new()
    .with_child_parse::<i32, _>(other_node)

Convenience method for handlers returning Pin<Box<Future>>s

Perform routing for a request

Trait Implementations

Returns the “default value” for a type. Read more

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

Performs the conversion.

Performs the conversion.

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.