pub fn from_slice<T>(b: &[u8]) -> Result<T>where
T: for<'de> Deserialize<'de> + 'static,Expand description
Deserialize YAML from a byte slice.
Convenience wrapper that validates b is UTF-8 then forwards
to from_str. Use when the caller already holds a &[u8]
(a buffer, a network frame, a bytes::Bytes) and would
otherwise have to round-trip through String.
§Errors
Error::Deserialize—bis not valid UTF-8.- All variants documented on
from_str.
§Examples
let n: i32 = noyalib::from_slice(b"42").unwrap();
assert_eq!(n, 42);