Skip to main content

SerializeAsBytes

Trait SerializeAsBytes 

Source
pub trait SerializeAsBytes {
    type Inner: FromBytes + Immutable + Copy;

    // Required methods
    fn as_bytes(&self) -> &[u8] ;
    fn from_vec(slice: Vec<Self::Inner>) -> Self;
}
Expand description

A trait for container types that can be efficiently serialized as a byte slice and reconstructed from a Vec of their elements.

Required Associated Types§

Required Methods§

Source

fn as_bytes(&self) -> &[u8]

Returns a byte slice that represents the container.

Source

fn from_vec(slice: Vec<Self::Inner>) -> Self

Constructs a container from a Vec of its elements.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: FromBytes + IntoBytes + Immutable + Copy> SerializeAsBytes for Box<[T]>

Source§

type Inner = T

Source§

fn as_bytes(&self) -> &[u8]

Source§

fn from_vec(slice: Vec<T>) -> Self

Source§

impl<T: FromBytes + IntoBytes + Immutable + Copy> SerializeAsBytes for Vec<T>

Source§

type Inner = T

Source§

fn as_bytes(&self) -> &[u8]

Source§

fn from_vec(slice: Vec<T>) -> Self

Implementors§