pub struct QueryParams { /* private fields */ }Expand description
Query parameters parsed from URL query string
Supports multiple values for the same key.
§Example
use gpui_navigator::QueryParams;
let query = QueryParams::from_query_string("page=1&sort=name&tag=rust&tag=gpui");
assert_eq!(query.get("page"), Some(&"1".to_string()));
assert_eq!(query.get_as::<i32>("page"), Some(1));
assert_eq!(query.get_all("tag").unwrap().len(), 2);Implementations§
Source§impl QueryParams
impl QueryParams
Sourcepub fn from_query_string(query: &str) -> Self
pub fn from_query_string(query: &str) -> Self
Parse from query string
§Example
use gpui_navigator::QueryParams;
let query = QueryParams::from_query_string("page=1&sort=name");
assert_eq!(query.get("page"), Some(&"1".to_string()));Sourcepub fn get_all(&self, key: &str) -> Option<&Vec<String>>
pub fn get_all(&self, key: &str) -> Option<&Vec<String>>
Get all values for a key.
Useful for parameters that can appear multiple times (e.g. ?tag=rust&tag=gpui).
Sourcepub fn get_as<T>(&self, key: &str) -> Option<T>where
T: FromStr,
pub fn get_as<T>(&self, key: &str) -> Option<T>where
T: FromStr,
Get the first value for a key, parsed as type T.
Returns None if the key is missing or the value cannot be parsed.
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>)
Append a value for the given key.
If the key already exists, the new value is added to the list (not replaced).
Sourcepub fn to_query_string(&self) -> String
pub fn to_query_string(&self) -> String
Serialize back into a query string.
§Example
use gpui_navigator::QueryParams;
let mut query = QueryParams::new();
query.insert("page".to_string(), "1".to_string());
let s = query.to_query_string();
assert!(s.contains("page=1"));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
Source§fn eq(&self, other: &QueryParams) -> bool
fn eq(&self, other: &QueryParams) -> bool
Tests for
self and other values to be equal, and is used by ==.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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<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§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().