Struct qstring::QString
[−]
[src]
pub struct QString { pub params: Vec<Param>, // some fields omitted }
A query string. Holds a list of Param
s.
Examples
Parameters are indexed by their names.
let qs = qstring::QString::from("?foo=bar%20baz"); let foo = &qs["foo"]; assert_eq!(foo, "bar baz");
Parameters not found are "".
let qs = qstring::QString::from("?foo=bar"); let foo = &qs["panda"]; assert_eq!(foo, "");
The query string can be assembled.
let qs = qstring::QString::new(vec![ qstring::Param::new("foo", "bar baz"), qstring::Param::new("panda", "true"), ]); assert_eq!(format!("{}", qs), "?&foo=bar%20baz&panda=true");
Can be looped over as Param
.
let qs = qstring::QString::from("?foo=bar"); for param in qs { assert_eq!(param.name, "foo"); assert_eq!(param.value, "bar"); assert_eq!(param, ("foo", "bar")); }
Fields
params: Vec<Param>
List of parameters in the query string.
Methods
impl QString
[src]
fn new(params: Vec<Param>) -> QString
[src]
Constructs a QString
from a list of Param
s.
let qs = qstring::QString::new(vec![ qstring::Param::new("foo", "bar baz"), qstring::Param::new("panda", "true"), ]); assert_eq!(format!("{}", qs), "?&foo=bar%20baz&panda=true");
Trait Implementations
impl Clone for QString
[src]
fn clone(&self) -> QString
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for QString
[src]
impl PartialEq for QString
[src]
fn eq(&self, __arg_0: &QString) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &QString) -> bool
[src]
This method tests for !=
.
impl<'a> From<&'a str> for QString
[src]
fn from(origin: &str) -> Self
[src]
Constructs a new QString
and find the Param
s therein.
Examples
let qs = qstring::QString::from("?foo=bar"); assert_eq!(qs.params, vec![("foo", "bar")]);
impl IntoIterator for QString
[src]
type Item = Param
The type of the elements being iterated over.
type IntoIter = IntoIter<Param>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'b> Index<&'b str> for QString
[src]
type Output = String
The returned type after indexing.
fn index(&self, index: &'b str) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.