Function bincode_core::deserialize[][src]

pub fn deserialize<'a, T: Deserialize<'a>, R: CoreRead<'a> + 'a, O: Options>(
    reader: R,
    options: O
) -> Result<T, DeserializeError<'a, R>>

Deserialize a given object from the given CoreRead object.

Rust will detect the first two generic arguments automatically. The third generic argument must be a valid byteorder::ByteOrder type. Normally this can be implemented like this:

let val: Type = deserialize::<_, _, byteorder::NetworkEndian>(&reader)?;

or

let val = deserialize::<Type, _, byteorder::NetworkEndian>(&reader)?;


#[derive(Deserialize, PartialEq, Debug)]
pub struct SomeStruct {
    a: u8,
    b: u8,
}
let buffer: [u8; 2] = [
    3, // a
    6, // b
];
let options = DefaultOptions::new();
let val: SomeStruct = deserialize(&buffer[..], options).unwrap();
assert_eq!(val, SomeStruct { a: 3, b: 6 });