pub struct QueryParams { /* private fields */ }Expand description
The query parameters of a request, in the order they were sent.
A name may repeat, which is how ?tag=a&tag=b asks for either tag.
Implementations§
Source§impl QueryParams
impl QueryParams
Sourcepub fn parse(query_string: &str) -> Self
pub fn parse(query_string: &str) -> Self
Parse a raw query string, with or without its leading ?.
§Examples
use lino_rest_api::query::QueryParams;
let query = QueryParams::parse("?tag=a&tag=b&limit=5");
assert_eq!(query.get_all("tag"), vec!["a", "b"]);
assert_eq!(query.get_last("limit"), Some("5"));Sourcepub fn append<N: Into<String>, V: Into<String>>(&mut self, name: N, value: V)
pub fn append<N: Into<String>, V: Into<String>>(&mut self, name: N, value: V)
Add one parameter, keeping any parameter of the same name.
Sourcepub fn get_last(&self, name: &str) -> Option<&str>
pub fn get_last(&self, name: &str) -> Option<&str>
The last value sent for a name, which is the one a scalar parameter means.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
The parameters, in the order they were sent.
Sourcepub fn names(&self) -> Vec<&str>
pub fn names(&self) -> Vec<&str>
The distinct parameter names, in the order they first appeared.
Sourcepub fn to_query_string(&self) -> String
pub fn to_query_string(&self) -> String
Render the parameters back as a query string.
Trait Implementations§
Source§impl Clone for QueryParams
impl Clone for QueryParams
Source§fn clone(&self) -> QueryParams
fn clone(&self) -> QueryParams
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 QueryParams
impl Debug for QueryParams
Source§impl Default for QueryParams
impl Default for QueryParams
Source§fn default() -> QueryParams
fn default() -> QueryParams
Returns the “default value” for a type. Read more
impl Eq for QueryParams
Source§impl PartialEq for QueryParams
impl PartialEq for QueryParams
impl StructuralPartialEq for QueryParams
Auto Trait Implementations§
impl Freeze for QueryParams
impl RefUnwindSafe for QueryParams
impl Send for QueryParams
impl Sync for QueryParams
impl Unpin for QueryParams
impl UnsafeUnpin for QueryParams
impl UnwindSafe for QueryParams
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.