Function bt_bencode::from_slice

source ·
pub fn from_slice<'a, T>(s: &'a [u8]) -> Result<T>
where T: Deserialize<'a>,
Expand description

Deserializes an instance of T from a slice of bytes.

The entire slice of bytes is consumed, and it is an error if there is trailing data. If trailing data is expected, then the Deserializer should be constructed directly. See Deserializer::byte_offset() for an example.

Errors

Deserialization can fail if the data is not valid, if the data cannot cannot be deserialized into an instance of T, if there is trailing data, and other IO errors.