pub fn encode<W, T>(writer: W, value: &T) -> Result<W::Ok, Error>Expand description
Encode the given value to the given Writer using the default
Encoding.
ยงExamples
use musli::{Decode, Encode};
use musli::packed;
#[derive(Decode, Encode)]
struct Person {
name: String,
age: u32,
}
let mut data = Vec::new();
packed::encode(&mut data, &Person {
name: "Aristotle".to_string(),
age: 61,
})?;
let person: Person = packed::from_slice(&data[..])?;
assert_eq!(person.name, "Aristotle");
assert_eq!(person.age, 61);