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(
&self,
ctx: &mut Context,
path: &str,
) -> Option<ServerHookHandler>
pub fn try_resolve_route( &self, ctx: &mut Context, path: &str, ) -> Option<ServerHookHandler>
Resolves and executes a route hook.
This method searches for a matching route and executes it if found. Finds a matching route hook for the given path.
§Arguments
&mut Context- The request context.&str- The request path to resolve.
§Returns
Option<ServerHookHandler>- The matched route hook if found, None otherwise.
Source§impl RouteMatcher
impl RouteMatcher
pub fn get_static_route(&self) -> &ServerHookMap
pub fn get_dynamic_route(&self) -> &ServerHookPatternRoute
pub fn get_regex_route(&self) -> &ServerHookPatternRoute
Source§impl RouteMatcher
impl RouteMatcher
pub fn get_mut_static_route(&mut self) -> &mut ServerHookMap
pub fn get_mut_dynamic_route(&mut self) -> &mut ServerHookPatternRoute
pub fn get_mut_regex_route(&mut self) -> &mut ServerHookPatternRoute
Trait Implementations§
Source§impl Clone for RouteMatcher
impl Clone for RouteMatcher
Source§fn clone(&self) -> RouteMatcher
fn clone(&self) -> RouteMatcher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RouteMatcher
impl Debug for RouteMatcher
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
impl Display for RouteMatcher
impl Eq for RouteMatcher
Implements the Eq trait for RouteMatcher.
This indicates that RouteMatcher has a total equality relation.