Function serde_html_form::de::from_str

source ·
pub fn from_str<'de, T>(input: &'de str) -> Result<T, Error>where
    T: Deserialize<'de>,
Expand description

Deserializes a application/x-www-form-urlencoded value from a &str.

let meal = vec![
    ("bread".to_owned(), "baguette".to_owned()),
    ("cheese".to_owned(), "comté".to_owned()),
    ("meat".to_owned(), "ham".to_owned()),
    ("fat".to_owned(), "butter".to_owned()),
];

assert_eq!(
    serde_html_form::from_str::<Vec<(String, String)>>(
        "bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter"
    ),
    Ok(meal)
);