pub trait Deserial {
    fn deserial<R>(_source: &mut R) -> Result<Self, ParseError>
    where
        R: Read
; }
Expand description

The Deserial trait provides a means of reading structures from byte-sources (Read).

Can be derived using #[derive(Deserial)] for most cases.

Required Methods

Attempt to read a structure from a given source, failing if an error occurs during deserialization or reading.

Implementations on Foreign Types

The deserialization of maps assumes their size is a u32.

WARNING: Deserialization only ensures that there are no duplicates. Serializing a HashMap via its Serial instance will not lay out elements in a particular order. As a consequence deserializing, and serializing back is in general not the identity. This could have consequences if the data is hashed, or the byte representation is used in some other way directly. In those cases use a BTreeMap instead.

The deserialization of sets assumes their size is a u32.

WARNING: Deserialization only ensures that there are no duplicates. Serializing a HashSet via its Serial instance will not lay out elements in any particular order. As a consequence deserializing, and serializing back is in general not the identity. This could have consequences if the data is hashed, or the byte representation is used in some other way directly. In those cases use a BTreeSet instead.

Deserializing a bool reads one byte, and returns the value false if the byte is 0u8 and true if the byte is 1u8, every other value results in an error.

Deserial by reading one byte, where 0u8 represents None and 1u8 represents Some, every other value results in an error. In the case of Some we deserialize using the contained T.

Implementors

Deserial by reading an u32 representing the number of bytes, then takes that number of bytes and tries to decode using utf8.

The deserialization of sets assumes their size is a u32.

WARNING: Deserialization does not ensure the ordering of the keys, it only ensures that there are no duplicates. Serializing a BTreeSet via its Serial instance will lay out elements by the increasing order. As a consequence deserializing, and serializing back is in general not the identity. This could have consequences if the data is hashed, or the byte representation is used in some other way directly. In those cases a canonical order should be ensured to avoid subtle, difficult to diagnose, bugs.

The deserialization of maps assumes their size is a u32.

WARNING: Deserialization does not ensure the ordering of the keys, it only ensures that there are no duplicates. Serializing a BTreeMap via its Serial instance will lay out elements by the increasing order of keys. As a consequence deserializing, and serializing back is in general not the identity. This could have consequences if the data is hashed, or the byte representation is used in some other way directly. In those cases the a canonical order should be ensured to avoid subtle, difficult to diagnose, bugs.

Deserialized by reading an u32 representing the number of elements, then deserializing that many elements of type T.