Function serde_cbor::from_reader [−][src]
pub fn from_reader<T, R>(reader: R) -> Result<T> where
T: DeserializeOwned,
R: Read,
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");