Trait Serialize

Source
pub trait Serialize {
    const SERIALIZED_SIZE: usize;

    // Required method
    fn serialize(&self, dst: &mut [u8]);
}
Expand description

Trait for describing how a type can be serialized into a constant-size byte slice.

Required Associated Constants§

Source

const SERIALIZED_SIZE: usize

The length of the buffer passed into Serialize::serialize.

Required Methods§

Source

fn serialize(&self, dst: &mut [u8])

Serializes the struct into the byte buffer. The length of dst must match the same type’s Serialize::SERIALIZED_SIZE constant.

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 Serialize for (u16, u16)

Source§

const SERIALIZED_SIZE: usize = 4usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for bool

Source§

const SERIALIZED_SIZE: usize = 1usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for u8

Source§

const SERIALIZED_SIZE: usize = 1usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for u16

Source§

const SERIALIZED_SIZE: usize = 2usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for u32

Source§

const SERIALIZED_SIZE: usize = 4usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for u64

Source§

const SERIALIZED_SIZE: usize = 8usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for Range<u32>

Source§

const SERIALIZED_SIZE: usize = 8usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl Serialize for Range<u64>

Source§

const SERIALIZED_SIZE: usize = 16usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl<T: Serialize, const LEN: usize> Serialize for ArrayVec<T, LEN>

Source§

const SERIALIZED_SIZE: usize

Source§

fn serialize(&self, dst: &mut [u8])

Source§

impl<const LEN: usize> Serialize for ArrayString<LEN>

Source§

const SERIALIZED_SIZE: usize

Source§

fn serialize(&self, dst: &mut [u8])

Implementors§