Struct matchit::Node [−][src]
pub struct Node<T> { /* fields omitted */ }
Expand description
A node in a radix tree ordered by priority.
Priority is just the number of values registered in sub nodes (children, grandchildren, and so on..).
Implementations
impl<T> Node<T>
[src]
impl<T> Node<T>
[src]pub fn insert(
&mut self,
route: impl Into<String>,
val: T
) -> Result<(), InsertError>
[src]
pub fn insert(
&mut self,
route: impl Into<String>,
val: T
) -> Result<(), InsertError>
[src]Register a value in the tree under the given route.
let mut matcher = Node::new(); matcher.insert("/home", "Welcome!")?; matcher.insert("/users/:id", "A User")?;
pub fn at<'p>(&self, path: &'p str) -> Result<Match<'_, 'p, &T>, MatchError>
[src]
pub fn at<'p>(&self, path: &'p str) -> Result<Match<'_, 'p, &T>, MatchError>
[src]Tries to find a value in the router matching the given path.
If no value can be found it returns a trailing slash redirect recommendation, see tsr
.
let mut matcher = Node::new(); matcher.insert("/home", "Welcome!")?; let matched = matcher.at("/home").unwrap(); assert_eq!(*matched.value, "Welcome!");
pub fn at_mut<'p>(
&mut self,
path: &'p str
) -> Result<Match<'_, 'p, &mut T>, MatchError>
[src]
pub fn at_mut<'p>(
&mut self,
path: &'p str
) -> Result<Match<'_, 'p, &mut T>, MatchError>
[src]Tries to find a value in the router matching the given path, and returns a mutable
reference to it. If no value can be found it returns a trailing slash redirect
recommendation, see tsr
.
pub fn path_ignore_case(
&self,
path: impl AsRef<str>,
fix_trailing_slash: bool
) -> Option<String>
[src]
pub fn path_ignore_case(
&self,
path: impl AsRef<str>,
fix_trailing_slash: bool
) -> Option<String>
[src]Makes a case-insensitive match of the given path and tries to find a handler. It can optionally also fix trailing slashes. If the match is successful, it returns the case corrected path.
let mut matcher = Node::new(); matcher.insert("/home", "Welcome!")?; let path = matcher.path_ignore_case("/HoMe/", true).unwrap(); assert_eq!(path, "/home");
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Node<T>
impl<T> Send for Node<T> where
T: Send,
T: Send,
impl<T> !Sync for Node<T>
impl<T> Unpin for Node<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Node<T> where
T: UnwindSafe,
T: UnwindSafe,