Struct Router
pub struct Router<T> { /* private fields */ }
A zero-copy URL router.
See the crate documentation for details.
Implementations
impl<T> Router<T>
fn new() -> SelfConstruct a new router.
fn insert(&mut self, route: impl Into<String>, value: T) -> Result<(), InsertError>Insert a route into the router.
Examples
# use Router; #fn at<'path>(&self, path: &'path str) -> Result<Match<'_, 'path, &T>, MatchError>Tries to find a value in the router matching the given path.
Examples
# use Router; #fn at_mut<'path>(&mut self, path: &'path str) -> Result<Match<'_, 'path, &mut T>, MatchError>Tries to find a value in the router matching the given path, returning a mutable reference.
Examples
# use Router; #fn remove(&mut self, path: impl Into<String>) -> Option<T>Remove a given route from the router.
Returns the value stored under the route if it was found. If the route was not found or invalid,
Noneis returned.Examples
# use Router; let mut router = new; router.insert; assert_eq!; assert_eq!; router.insert; assert_eq!; assert_eq!; router.insert; // the route does not match assert_eq!; assert_eq!; router.insert; // invalid route assert_eq!; assert_eq!;
Trait Implementations
impl<T> Default for Router<T>
fn default() -> Self
impl<T: Clone> Clone for Router<T>
fn clone(&self) -> Router<T>
impl<T: Debug> Debug for Router<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T> !Freeze for Router<T>
impl<T> !RefUnwindSafe for Router<T>
impl<T> Send for Router<T>
where
Node<T>: Send,
impl<T> Sync for Router<T>
where
Node<T>: Sync,
impl<T> Unpin for Router<T>
where
Node<T>: Unpin,
impl<T> UnsafeUnpin for Router<T>
where
Node<T>: UnsafeUnpin,
impl<T> UnwindSafe for Router<T>
where
Node<T>: UnwindSafe,
Blanket Implementations
impl<T> Any for Router<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Router<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Router<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Router<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Router<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Router<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Router<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Router<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Router<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>