Trait ncomm_utils::packing::Packable
source · pub trait Packable: Sized {
// Required methods
fn len() -> usize;
fn pack(self, buffer: &mut [u8]) -> Result<(), PackingError>;
fn unpack(data: &[u8]) -> Result<Self, PackingError>;
}Expand description
Trait implemented by data to be sent over network boundaries.
Required Methods§
sourcefn pack(self, buffer: &mut [u8]) -> Result<(), PackingError>
fn pack(self, buffer: &mut [u8]) -> Result<(), PackingError>
Pack a given piece of data into a given buffer.
Note: this format of pack was utilized to make this trait
compatible with both std and no_std targets (specifically
for no_std targets without alloc)
sourcefn unpack(data: &[u8]) -> Result<Self, PackingError>
fn unpack(data: &[u8]) -> Result<Self, PackingError>
Unpack a given piece of data from an array of bytes
Object Safety§
This trait is not object safe.