pub struct RoutePattern {
pub original_path: String,
pub segments: Vec<PathSegment>,
pub param_names: Vec<String>,
pub has_catch_all: bool,
pub static_segments: usize,
}
Expand description
Parsed route pattern with compiled segments
Fields§
§original_path: String
The original path string
segments: Vec<PathSegment>
Parsed path segments
param_names: Vec<String>
Parameter names in order
has_catch_all: bool
Whether this pattern has a catch-all segment
static_segments: usize
Number of static segments (for priority calculation)
Implementations§
Source§impl RoutePattern
impl RoutePattern
Sourcepub fn parse(path: &str) -> Result<Self, RoutePatternError>
pub fn parse(path: &str) -> Result<Self, RoutePatternError>
Parse a route pattern from a path string
Sourcepub fn extract_params(&self, path: &str) -> HashMap<String, String>
pub fn extract_params(&self, path: &str) -> HashMap<String, String>
Extract parameter values from a path that matches this pattern
Sourcepub fn priority(&self) -> usize
pub fn priority(&self) -> usize
Calculate priority for route matching (lower = higher priority)
Priority system accounts for constraint specificity:
- Static segment: 1 (highest priority)
- Parameter with specific constraint (Int, Uuid): 5
- Parameter with general constraint (Alpha, Slug): 8
- Parameter with custom regex constraint: 6 (between specific and general)
- Parameter with no constraint: 10
- Catch-all segment: 100 (lowest priority)
Trait Implementations§
Source§impl Clone for RoutePattern
impl Clone for RoutePattern
Source§fn clone(&self) -> RoutePattern
fn clone(&self) -> RoutePattern
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for RoutePattern
impl RefUnwindSafe for RoutePattern
impl Send for RoutePattern
impl Sync for RoutePattern
impl Unpin for RoutePattern
impl UnwindSafe for RoutePattern
Blanket Implementations§
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
Mutably borrows from an owned value. Read more