Function serde_cbor::from_slice [−][src]
pub fn from_slice<'a, T>(slice: &'a [u8]) -> Result<T> where
T: Deserialize<'a>,
Decodes a value from CBOR data in a slice.
Examples
Deserialize a String
let v: Vec<u8> = vec![0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]; let value: String = de::from_slice(&v[..]).unwrap(); assert_eq!(value, "foobar");
Deserialize a borrowed string with zero copies.
let v: Vec<u8> = vec![0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]; let value: &str = de::from_slice(&v[..]).unwrap(); assert_eq!(value, "foobar");