Function serde_qs::from_bytes
source · pub fn from_bytes<'de, T: Deserialize<'de>>(
input: &'de [u8]
) -> Result<T, Error>
Expand description
Deserializes a querystring from a &[u8]
.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
struct Query {
name: String,
age: u8,
occupation: String,
}
let q = Query {
name: "Alice".to_owned(),
age: 24,
occupation: "Student".to_owned(),
};
assert_eq!(
serde_qs::from_bytes::<Query>(
"name=Alice&age=24&occupation=Student".as_bytes()
).unwrap(), q);