Function forest_filecoin::utils::encoding::fallback_de_ipld_dagcbor::from_reader
source · pub fn from_reader<T, R>(reader: R) -> Result<T, DecodeError<Error>>where
T: DeserializeOwned,
R: BufRead,
Expand description
Decodes a value from CBOR data in a reader.
§Examples
De-serialize 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");