pub trait DeserializableSlice<const N: usize>: Serializable<N> {
    // Provided methods
    fn from_slice(buf: &[u8]) -> Result<Self, Self::Error>
       where Self: Sized,
             Self::Error: BadLength { ... }
    fn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>
       where R: Read,
             Self: Sized,
             Self::Error: BadLength { ... }
}
Expand description

An optional trait used to implement [from_slice] on top of types that uses Serializable trait. The default implementation makes use of Serializable trait to provide the necessary deserialization functionality without additional code from the consumer.

Provided Methods§

source

fn from_slice(buf: &[u8]) -> Result<Self, Self::Error>
where Self: Sized, Self::Error: BadLength,

Deserialize a slice of u8 into Self

source

fn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>
where R: Read, Self: Sized, Self::Error: BadLength,

Deserialize the type reading the bytes from a reader. The bytes read are removed from the reader.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, const N: usize> DeserializableSlice<N> for T
where T: Serializable<N>,