Struct qstring::QString [] [src]

pub struct QString {
    pub params: Vec<Param>,
    // some fields omitted
}

A query string. Holds a list of Params.

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

List of parameters in the query string.

Methods

impl QString
[src]

[src]

Constructs a QString from a list of Params.

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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for QString
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for QString
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<'a> From<&'a str> for QString
[src]

[src]

Constructs a new QString and find the Params therein.

Examples

let qs = qstring::QString::from("?foo=bar");
assert_eq!(qs.params, vec![("foo", "bar")]);

impl IntoIterator for QString
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<'b> Index<&'b str> for QString
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl Display for QString
[src]

[src]

Formats the value using the given formatter. Read more