deserialize

Function deserialize 

Source
pub fn deserialize<'de, T>(src: &'de [u8]) -> ReadResult<T>
where T: SchemaRead<'de, Dst = T>,
Expand description

Deserialize a type from the given bytes.

This is a “simplified” version of Deserialize::deserialize that requires the T::Dst to be T. In other words, a schema type that deserializes to itself.

This helper exists to match the expected signature of serde’s Deserialize, where types that implement Deserialize deserialize into themselves. This will be true of a large number of schema types, but wont, for example, for specialized container structures.

§Examples

let vec: Vec<u8> = vec![1, 2, 3];
let bytes = wincode::serialize(&vec).unwrap();
let deserialized: Vec<u8> = wincode::deserialize(&bytes).unwrap();
assert_eq!(vec, deserialized);