pub fn from_reader<T, R>(reader: R) -> Result<T>where
T: DeserializeOwned,
R: Read,
Expand description
Decodes a value from CBOR data in a reader.
§Examples
Deserialize a String
let v: Vec<u8> = vec![0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72];
let value: String = de::from_reader(&v[..]).unwrap();
assert_eq!(value, "foobar");
Note that from_reader
cannot borrow data:
ⓘ
let v: Vec<u8> = vec![0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72];
let value: &str = de::from_reader(&v[..]).unwrap();
assert_eq!(value, "foobar");