pub struct RouteMatcher { /* private fields */ }Expand description
The core routing engine responsible for matching request paths to their corresponding handlers.
The matcher categorizes route into three types for optimized performance:
static_route- For exact path matches, offering the fastest lookups.dynamic_route- For paths with variable segments.regex_route- For complex matching based on regular expressions.
When a request comes in, the matcher checks these categories in order to find the appropriate hook.
Implementations§
Source§impl RouteMatcher
Manages a collection of route, enabling efficient lookup and dispatch.
impl RouteMatcher
Manages a collection of route, enabling efficient lookup and dispatch.
This struct stores route categorized by type (static, dynamic, regex) to quickly find the appropriate hook for incoming requests.
Sourcepub fn try_resolve_route<'a>(
&'a self,
ctx: &mut Context,
path: &str,
) -> Option<&'a ServerHookHandler>
pub fn try_resolve_route<'a>( &'a self, ctx: &mut Context, path: &str, ) -> Option<&'a ServerHookHandler>
Resolves a route hook by reference (no Arc::clone) for hot-path use.
Returns a reference to the matched ServerHookHandler if any. The
caller must clone if it needs to retain the hook beyond the await point.
Returns None if no route matched.
§Arguments
&'a self- The route table to search.&mut Context- The request context (for storing route params).&str- The request path to resolve.
§Returns
Option<&'a ServerHookHandler>: The matched handler, orNonewhen no route matched.
Source§impl RouteMatcher
Implements impl #impl_generics #name #ty_generics #where_clause.
impl RouteMatcher
Implements impl #impl_generics #name #ty_generics #where_clause.
pub fn get_static_route(&self) -> &HashMapXxHash3_64<String, ServerHookHandler>
pub fn get_mut_static_route( &mut self, ) -> &mut HashMapXxHash3_64<String, ServerHookHandler>
pub fn get_dynamic_route(&self) -> &ServerHookPatternRoute
pub fn get_mut_dynamic_route(&mut self) -> &mut ServerHookPatternRoute
pub fn get_regex_route(&self) -> &ServerHookPatternRoute
pub fn get_mut_regex_route(&mut self) -> &mut ServerHookPatternRoute
Trait Implementations§
Source§impl Clone for RouteMatcher
impl Clone for RouteMatcher
Source§impl Debug for RouteMatcher
Implements impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause.
impl Debug for RouteMatcher
Implements impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause.
Source§impl Default for RouteMatcher
Provides a default implementation for RouteMatcher.
impl Default for RouteMatcher
Provides a default implementation for RouteMatcher.
Source§impl Display for RouteMatcher
Implements impl #impl_generics ::std::fmt::Display for #name #ty_generics #where_clause.
impl Display for RouteMatcher
Implements impl #impl_generics ::std::fmt::Display for #name #ty_generics #where_clause.
Source§impl Eq for RouteMatcher
Implements the Eq trait for RouteMatcher.
impl Eq for RouteMatcher
Implements the Eq trait for RouteMatcher.
This indicates that RouteMatcher has a total equality relation.
Auto Trait Implementations§
impl !RefUnwindSafe for RouteMatcher
impl !UnwindSafe for RouteMatcher
impl Forget for RouteMatcher
impl Freeze for RouteMatcherwhere
PhantomData<fn() -> XxHash3_64>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(String, Arc<dyn Fn(&mut Stream, &mut Context) -> Pin<Box<dyn Future<Output = Status> + Send>> + Sync + Send>)>: Freeze,
PhantomData<(usize, Vec<(RoutePattern, Arc<dyn Fn(&mut Stream, &mut Context) -> Pin<Box<dyn Future<Output = Status> + Send>> + Sync + Send>)>)>: Freeze,
impl Move for RouteMatcher
impl Send for RouteMatcher
impl Sync for RouteMatcher
impl Unpin for RouteMatcher
impl UnsafeUnpin for RouteMatcherwhere
PhantomData<fn() -> XxHash3_64>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, Arc<dyn Fn(&mut Stream, &mut Context) -> Pin<Box<dyn Future<Output = Status> + Send>> + Sync + Send>)>: UnsafeUnpin,
PhantomData<(usize, Vec<(RoutePattern, Arc<dyn Fn(&mut Stream, &mut Context) -> Pin<Box<dyn Future<Output = Status> + Send>> + Sync + Send>)>)>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.