pub fn from_slice<'de, T>(bytes: &'de [u8]) -> Result<T, Error>Expand description
Decode the given type T from the given slice using the default
Encoding.
ยงExamples
use musli::{Decode, Encode};
use musli::packed;
#[derive(Decode, Encode)]
struct Person {
name: String,
age: u32,
}
let data = packed::to_vec(&Person {
name: "Aristotle".to_string(),
age: 61,
})?;
let person: Person = packed::from_slice(&data[..])?;
assert_eq!(person.name, "Aristotle");
assert_eq!(person.age, 61);