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 parameter
Useful for parameters that can appear multiple times like ?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 parameter as a specific type
Returns the first value parsed as type T.
Sourcepub fn insert(&mut self, key: String, value: String)
pub fn insert(&mut self, key: String, value: String)
Insert a parameter
If the key already exists, the value is appended to the list.
Sourcepub fn to_query_string(&self) -> String
pub fn to_query_string(&self) -> String
Convert to 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 · 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
Auto Trait Implementations§
impl Freeze for QueryParams
impl RefUnwindSafe for QueryParams
impl Send for QueryParams
impl Sync for QueryParams
impl Unpin 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<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().