Trait packed_struct::PackedStruct
source · pub trait PackedStructwhere
Self: Sized,{
type ByteArray: ByteArray;
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.