Skip to main content

RouteMatch

Struct RouteMatch 

Source
pub struct RouteMatch<'a> {
    pub route: &'a Route,
    pub params: Vec<(&'a str, &'a str)>,
}
Expand description

A matched route with extracted parameters.

Fields§

§route: &'a Route

The matched route.

§params: Vec<(&'a str, &'a str)>

Extracted path parameters.

Implementations§

Source§

impl<'a> RouteMatch<'a>

Source

pub fn get_param(&self, name: &str) -> Option<&str>

Get a parameter value by name as a string slice.

Source

pub fn get_param_int(&self, name: &str) -> Option<Result<i64, ParseIntError>>

Get a parameter value parsed as an i64 integer.

Returns None if the parameter doesn’t exist. Returns Some(Err(_)) if the parameter exists but can’t be parsed as i64.

§Example
// Route: /users/{id:int}
if let Some(Ok(id)) = route_match.get_param_int("id") {
    println!("User ID: {id}");
}
Source

pub fn get_param_i32(&self, name: &str) -> Option<Result<i32, ParseIntError>>

Get a parameter value parsed as an i32 integer.

Returns None if the parameter doesn’t exist. Returns Some(Err(_)) if the parameter exists but can’t be parsed as i32.

Source

pub fn get_param_u64(&self, name: &str) -> Option<Result<u64, ParseIntError>>

Get a parameter value parsed as a u64 unsigned integer.

Returns None if the parameter doesn’t exist. Returns Some(Err(_)) if the parameter exists but can’t be parsed as u64.

Source

pub fn get_param_u32(&self, name: &str) -> Option<Result<u32, ParseIntError>>

Get a parameter value parsed as a u32 unsigned integer.

Returns None if the parameter doesn’t exist. Returns Some(Err(_)) if the parameter exists but can’t be parsed as u32.

Source

pub fn get_param_float( &self, name: &str, ) -> Option<Result<f64, ParseFloatError>>

Get a parameter value parsed as an f64 float.

Returns None if the parameter doesn’t exist. Returns Some(Err(_)) if the parameter exists but can’t be parsed as f64.

§Example
// Route: /values/{val:float}
if let Some(Ok(val)) = route_match.get_param_float("val") {
    println!("Value: {val}");
}
Source

pub fn get_param_f32(&self, name: &str) -> Option<Result<f32, ParseFloatError>>

Get a parameter value parsed as an f32 float.

Returns None if the parameter doesn’t exist. Returns Some(Err(_)) if the parameter exists but can’t be parsed as f32.

Source

pub fn is_param_uuid(&self, name: &str) -> Option<bool>

Check if a parameter value is a valid UUID format.

Returns None if the parameter doesn’t exist. Returns Some(true) if the parameter is a valid UUID. Returns Some(false) if the parameter exists but isn’t a valid UUID.

Source

pub fn param_count(&self) -> usize

Get parameter count.

Source

pub fn is_empty(&self) -> bool

Check if there are no parameters.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>

Iterate over all parameters as (name, value) pairs.

Trait Implementations§

Source§

impl<'a> Debug for RouteMatch<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RouteMatch<'a>

§

impl<'a> !RefUnwindSafe for RouteMatch<'a>

§

impl<'a> Send for RouteMatch<'a>

§

impl<'a> Sync for RouteMatch<'a>

§

impl<'a> Unpin for RouteMatch<'a>

§

impl<'a> !UnwindSafe for RouteMatch<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ResponseProduces<T> for T