[−][src]Struct net::url::Values
Values maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive.
Example
use net::url::Values; fn main() { let mut v = Values::default(); v.set("name".to_string(), "Ava"); v.add("friend", "Jess"); v.add("friend", "Sarah"); v.add("friend", "Zoe"); // v.Encode() == "name=Ava&friend=Jess&friend=Sarah&friend=Zoe" assert_eq!(v.get("name").unwrap(), "Ava"); assert_eq!(v.get("friend").unwrap(), "Jess"); let friends: Vec<String> = vec!["Jess", "Sarah", "Zoe"] .iter() .map(|v| v.to_string()) .collect(); assert_eq!(v.0["friend"], friends); }
Implementations
impl Values
[src]
pub fn add<K, V>(&mut self, key: K, value: V) where
K: ToString,
V: ToString,
[src]
K: ToString,
V: ToString,
add adds the value to key. It appends to any existing values associated with key.
pub fn del(&mut self, key: &str)
[src]
del deletes the values associated with key.
pub fn encode(&self) -> String
[src]
encode encodes the values into "URL encoded" form ("bar=baz&foo=quux") sorted by key.
pub fn get(&self, key: &str) -> Option<&str>
[src]
get gets the first value associated with the given key. If there are no values associated with the key, get returns None. To access multiple values, use the map directly.
pub fn set<K, V>(&mut self, key: K, value: V) where
K: ToString,
V: ToString,
[src]
K: ToString,
V: ToString,
set sets the key to value. It replaces any existing values.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Values
impl Send for Values
impl Sync for Values
impl Unpin for Values
impl UnwindSafe for Values
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,