pub struct PathParams { /* private fields */ }Expand description
Ordered collection of path parameters extracted from a URL pattern.
Preserves insertion order so that tuple extractors like Path<(T1, T2)>
can rely on URL pattern declaration order when populating tuple fields.
§Example
use reinhardt_http::PathParams;
let mut params = PathParams::new();
params.insert("org", "myslug");
params.insert("cluster_id", "5");
// Insertion order is preserved.
let collected: Vec<_> = params.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
assert_eq!(collected, vec![("org", "myslug"), ("cluster_id", "5")]);
// Named lookup still works.
assert_eq!(params.get("org").map(String::as_str), Some("myslug"));Implementations§
Source§impl PathParams
impl PathParams
Sourcepub fn get(&self, key: &str) -> Option<&String>
pub fn get(&self, key: &str) -> Option<&String>
Look up a parameter by name.
Returns the first match if multiple entries share the same name (which should not happen in practice because URL patterns require unique names).
Sourcepub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
Insert or update a parameter.
If key already exists, its value is replaced and its position is kept.
Otherwise the new entry is appended, preserving insertion order.
Sourcepub fn iter(&self) -> Iter<'_, (String, String)>
pub fn iter(&self) -> Iter<'_, (String, String)>
Iterate over (key, value) pairs in insertion order.
Trait Implementations§
Source§impl Clone for PathParams
impl Clone for PathParams
Source§fn clone(&self) -> PathParams
fn clone(&self) -> PathParams
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PathParams
impl Debug for PathParams
Source§impl Default for PathParams
impl Default for PathParams
Source§fn default() -> PathParams
fn default() -> PathParams
Returns the “default value” for a type. Read more
Source§impl<K, V> FromIterator<(K, V)> for PathParams
impl<K, V> FromIterator<(K, V)> for PathParams
Source§impl<'a> IntoIterator for &'a PathParams
impl<'a> IntoIterator for &'a PathParams
Source§impl IntoIterator for PathParams
impl IntoIterator for PathParams
Source§impl PartialEq for PathParams
impl PartialEq for PathParams
Source§fn eq(&self, other: &PathParams) -> bool
fn eq(&self, other: &PathParams) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for PathParams
impl StructuralPartialEq for PathParams
Auto Trait Implementations§
impl Freeze for PathParams
impl RefUnwindSafe for PathParams
impl Send for PathParams
impl Sync for PathParams
impl Unpin for PathParams
impl UnsafeUnpin for PathParams
impl UnwindSafe for PathParams
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
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
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().