pub fn to_writer<T: Serialize, W: Write>(
input: &T,
writer: &mut W,
) -> Result<(), Error>
Expand description
Serializes a value into a generic writer object.
#[derive(Deserialize, Serialize)]
struct Query {
name: String,
age: u8,
occupation: String,
}
let q = Query {
name: "Alice".to_owned(),
age: 24,
occupation: "Student".to_owned(),
};
let mut buffer = Vec::new();
serde_qs::to_writer(&q, &mut buffer).unwrap();
assert_eq!(
String::from_utf8(buffer).unwrap(),
"name=Alice&age=24&occupation=Student");