Trait byte_struct::ByteStruct [−][src]
pub trait ByteStruct: ByteStructLen {
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
fn write_bytes(&self, bytes: &mut [u8])
fn write_bytes(&self, bytes: &mut [u8])
Packs the struct into raw bytes and write to a slice
fn read_bytes(bytes: &[u8]) -> Self
fn read_bytes(bytes: &[u8]) -> Self
Unpacks raw bytes from a slice into a new struct