[][src]Trait byte_struct::ByteStruct

pub trait ByteStruct {
    fn write_bytes(&self, bytes: &mut [u8]);
fn read_bytes(bytes: &[u8]) -> Self; }

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

This trait can be derived by either #[derive(ByteStructLE)] or #[derive(ByteStructBE)]. The difference between two macros is byte order specification. LE is for little-endian, and BE is for big-endian. All members of the struct to derive must implement ByteStructImpl.

Required methods

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

Packs the struct into raw bytes and write to a slice

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

Unpacks raw bytes from a slice into a new struct

Loading content...

Implementors

Loading content...