Skip to main content

from_bytes

Function from_bytes 

Source
pub fn from_bytes<'de, T: FromJson<'de>>(
    bytes: &'de [u8],
) -> Result<T, DecodeError>
Expand description

Reads bytes, which must be UTF-8, as one T; see from_str.

§Errors

As from_str, plus ErrorKind::InvalidUtf8 and ErrorKind::InputTooLarge as for parse_bytes.

§Examples

let pair: (bool, u8) = jsonx_lib::from_bytes(b"[true, 2]")?;
assert_eq!(pair, (true, 2));