Skip to main content

Path

Struct Path 

Source
pub struct Path<T> { /* private fields */ }
Expand description

Resource path match information

Wraps a path source and stores the values of dynamic segments matched by a Router.

Implementations§

Source§

impl<T> Path<T>
where T: ResourcePath,

Source

pub fn new(resource: T) -> Path<T>

Creates a new path state for the path source.

Source

pub fn get_ref(&self) -> &T

Get reference to inner path instance

Source

pub fn get_mut(&mut self) -> &mut T

Get mutable reference to inner path instance

Source

pub fn into_inner(self) -> T

Consume the path state and return the inner path instance

Source

pub fn path(&self) -> &str

Path that is not matched yet, e.g. the rest of the path after a prefix resource matched.

Unlike get_ref().path(), which is the full path, it excludes the skipped part of the path.

Source

pub fn set(&mut self, resource: T)

Set new path source and reset state

Source

pub fn reset(&mut self)

Reset skipped length and matched segments

Source

pub fn skip(&mut self, n: u32)

Skip first n bytes in path, matching starts after them

The skipped length is limited to the path length.

Source

pub fn is_empty(&self) -> bool

Check if there are any matched segments

Source

pub fn len(&self) -> usize

Number of matched segments

Source

pub fn get(&self, key: &str) -> Option<&str>

Get matched segment by name without type conversion

If no segment is named tail, the tail key returns the unprocessed part of the path, see path().

Source

pub fn iter(&self) -> PathIter<'_, T> ⓘ

Iterator over matched segments as (name, value) pairs, in pattern order

Source

pub fn load<'de, U>(&'de self) -> Result<U, Error>
where U: Deserialize<'de>,

Try to deserialize matched segments to a specified type U

See PathDeserializer.

Trait Implementations§

Source§

impl<T> Clone for Path<T>
where T: Clone,

Source§

fn clone(&self) -> Path<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Path<T>
where T: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Path<T>
where T: Default,

Source§

fn default() -> Path<T>

Returns the “default value” for a type. Read more
Source§

impl<'a, T> Index<&'a str> for Path<T>
where T: ResourcePath,

Source§

type Output = str

The returned type after indexing.
Source§

fn index(&self, name: &'a str) -> &str

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<usize> for Path<T>
where T: ResourcePath,

Source§

type Output = str

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &str

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a Path<T>
where T: ResourcePath,

Source§

type Item = (&'a str, &'a str)

The type of the elements being iterated over.
Source§

type IntoIter = PathIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> PathIter<'a, T> ⓘ

Creates an iterator from a value. Read more
Source§

impl<T> Resource<T> for Path<T>
where T: ResourcePath,

Source§

fn path(&self) -> &str

Path to match.
Source§

fn resource_path(&mut self) -> &mut Path<T>

Path state that stores match results.

Auto Trait Implementations§

§

impl<T> Freeze for Path<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Path<T>
where T: RefUnwindSafe,

§

impl<T> Send for Path<T>
where T: Send,

§

impl<T> Sync for Path<T>
where T: Sync,

§

impl<T> Unpin for Path<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Path<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Path<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.