pub trait DeserializeBytes: Size {
    // Required method
    fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>
       where Self: Sized;

    // Provided method
    fn tls_deserialize_exact_bytes(bytes: &[u8]) -> Result<Self, Error>
       where Self: Sized { ... }
}
Expand description

The DeserializeBytes trait defines functions to deserialize a byte slice to a struct or enum. In contrast to Deserialize, this trait operates directly on byte slices and can return any remaining bytes.

Required Methods§

source

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

This function deserializes the bytes from the provided a &[u8] and returns the populated struct, as well as the remaining slice.

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(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized,

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.

Implementations on Foreign Types§

source§

impl DeserializeBytes for u8

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl DeserializeBytes for u16

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl DeserializeBytes for u32

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl DeserializeBytes for u64

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl DeserializeBytes for ()

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl<T> DeserializeBytes for PhantomData<T>

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl<T, U> DeserializeBytes for (T, U)

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl<T, U, V> DeserializeBytes for (T, U, V)

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl<T: DeserializeBytes> DeserializeBytes for Option<T>

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

impl<T: DeserializeBytes> DeserializeBytes for Vec<T>

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

source§

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

source§

fn tls_deserialize_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

Implementors§