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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".