pub fn from_slice<'a, R, T>(input: &'a R) -> Result<T> where
    R: AsRef<[u8]> + ?Sized,
    T: Deserialize<'a>, 
Expand description

Deserialize a temporary scoped-bound instance of type T from a slice, with zero-copy if possible.

Deserialization will be performed in zero-copy manner whenever it is possible, borrowing the data from the slice itself. For example, strings and byte-arrays won’t copied.

Examples

let buf = b"*2\r\n:42\r\n+the Answer\r\n";
let r: (usize, &str) = deseresp::from_slice(&buf).unwrap();
assert_eq!(r, (42, "the Answer"));