Trait winter_utils::Deserializable

source ·
pub trait Deserializable: Sized {
    // Required method
    fn read_from<R: ByteReader>(
        source: &mut R
    ) -> Result<Self, DeserializationError>;

    // Provided method
    fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError> { ... }
}
Expand description

Defines how to deserialize Self from bytes.

Required Methods§

source

fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result.

§Errors

Returns an error if:

  • The source does not contain enough bytes to deserialize Self.
  • Bytes read from the source do not represent a valid value for Self.

Provided Methods§

source

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result.

§Errors

Returns an error if:

  • The bytes do not contain enough information to deserialize Self.
  • The bytes do not represent a valid value for Self.

Note: if bytes contains more data than needed to deserialize self, no error is returned.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Deserializable for u8

source§

impl Deserializable for u16

source§

impl Deserializable for u32

source§

impl Deserializable for u64

source§

impl Deserializable for u128

source§

impl Deserializable for ()

source§

impl Deserializable for usize

source§

impl Deserializable for String

source§

impl<K: Deserializable + Ord, V: Deserializable> Deserializable for BTreeMap<K, V>

source§

impl<T1> Deserializable for (T1,)
where T1: Deserializable,

source§

impl<T1, T2> Deserializable for (T1, T2)

source§

impl<T1, T2, T3> Deserializable for (T1, T2, T3)

source§

impl<T1, T2, T3, T4> Deserializable for (T1, T2, T3, T4)

source§

impl<T1, T2, T3, T4, T5> Deserializable for (T1, T2, T3, T4, T5)

source§

impl<T1, T2, T3, T4, T5, T6> Deserializable for (T1, T2, T3, T4, T5, T6)

source§

impl<T: Deserializable + Ord> Deserializable for BTreeSet<T>

source§

impl<T: Deserializable> Deserializable for Option<T>

source§

impl<T: Deserializable> Deserializable for Vec<T>

source§

impl<T: Deserializable, const C: usize> Deserializable for [T; C]

Implementors§