Struct path_router::Tree
[−]
[src]
pub struct Tree<'a, T> { /* fields omitted */ }
The routing information is stored as a trie.
Description
Each node is labelled with its path segment. The value is a tuple. The first element is generic, and is usually a handler function; the second element is the captured path segments.
Methods
impl<'a, T> Tree<'a, T>
[src]
fn new<'b>() -> Tree<'b, T>
Constructs a new routing tree.
fn add(&mut self, key: &'a str, value: T)
Adds a new path and its associated value to the tree. Prefix a segment with a colon (:) to enable capturing on the segment.
Panics
Panics if a duplicate route is added.
fn find<'b>(&self, key: &'b str) -> Option<(&T, Vec<(&'a str, &'b str)>)>
Retrieve the value associated with the path, together with the captured path segments.