pub trait ByteStruct: ByteStructLen {
    // Required methods
    fn write_bytes(&self, bytes: &mut [u8]);
    fn read_bytes(bytes: &[u8]) -> Self;
}
Expand description

A data structure that can be packed into or unpacked from raw bytes.

This trait can be derived by #[derive(ByteStruct)].

One can implement this trait for custom types in order to pack or unpack an object in a special way.

Required Methods§

source

fn write_bytes(&self, bytes: &mut [u8])

Packs the struct into raw bytes and write to a slice

source

fn read_bytes(bytes: &[u8]) -> Self

Unpacks raw bytes from a slice into a new struct

Implementors§