pub fn deserialize<'a, T>(
subject: &'a [u8],
format: &SerializationFormat,
) -> Result<T, SerializationError>where
T: Deserialize<'a>,
Expand description
Attempts to deserialise subject
using format
into T
.
§Arguments
subject
: TheVec<u8>
that representsT
in binary format.format
: The format to use when deserialisingsubject
.
returns: Result<T>
§Errors
This method returns a SerializationError
if any of the steps for deserialization fails.
See SerializationError
for specific details on each error scenario.
§Examples
let json = b"{ \"bar\": \"baz\" }";
deserialize::<Foo>(json, &SerializationFormat::JSON)?;