pub trait PackedStructwhere
Self: Sized,{
type ByteArray: ByteArray;
// Required methods
fn pack(&self) -> PackingResult<Self::ByteArray>;
fn unpack(src: &Self::ByteArray) -> PackingResult<Self>;
}Expand description
A structure that can be packed and unpacked from a byte array.
In case the structure occupies less bits than there are in the byte array, the packed that should be aligned to the end of the array, with leading bits being ignored.
10 bits packs into: [0b00000011, 0b11111111]
Required Associated Types§
Required Methods§
Sourcefn pack(&self) -> PackingResult<Self::ByteArray>
fn pack(&self) -> PackingResult<Self::ByteArray>
Packs the structure into a byte array.
Sourcefn unpack(src: &Self::ByteArray) -> PackingResult<Self>
fn unpack(src: &Self::ByteArray) -> PackingResult<Self>
Unpacks the structure from a byte array.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.