pub trait Deserialize: Size {
    // Required method
    fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>
       where Self: Sized;

    // Provided methods
    fn tls_deserialize_exact(bytes: impl AsRef<[u8]>) -> Result<Self, Error>
       where Self: Sized { ... }
    fn tls_deserialize_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, Error>
       where Self: Sized { ... }
}
Expand description

The Deserialize trait defines functions to deserialize a byte slice to a struct or enum.

Required Methods§

source

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>where Self: Sized,

Available on crate feature std only.

This function deserializes the bytes from the provided a std::io::Read and returns the populated struct.

In order to get the amount of bytes read, use Size::tls_serialized_len.

Returns an error if one occurs during deserialization.

Provided Methods§

source

fn tls_deserialize_exact(bytes: impl AsRef<[u8]>) -> Result<Self, Error>where Self: Sized,

Available on crate feature std only.

This function deserializes the provided bytes and returns the populated struct. All bytes must be consumed.

Returns an error if not all bytes are read from the input, or if an error occurs during deserialization.

source

fn tls_deserialize_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, Error>where Self: Sized,

Available on crate feature std only.

This function deserializes the provided bytes and returns the populated struct.

Returns an error if one occurs during deserialization.

Implementations on Foreign Types§

source§

impl<T: Deserialize> Deserialize for Vec<T>

Available on crate feature std only.
source§

impl Deserialize for u8

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl<T, U, V> Deserialize for (T, U, V)where T: Deserialize, U: Deserialize, V: Deserialize,

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl Deserialize for ()

source§

fn tls_deserialize<R: Read>(_: &mut R) -> Result<(), Error>

Available on crate feature std only.
source§

impl Deserialize for u32

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl<const LEN: usize> Deserialize for [u8; LEN]

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl<T: Deserialize> Deserialize for Option<T>

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl<T> Deserialize for PhantomData<T>

source§

fn tls_deserialize<R: Read>(_: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl<T, U> Deserialize for (T, U)where T: Deserialize, U: Deserialize,

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl Deserialize for u16

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.
source§

impl Deserialize for u64

source§

fn tls_deserialize<R: Read>(bytes: &mut R) -> Result<Self, Error>

Available on crate feature std only.

Implementors§