Trait packed_struct::prelude::PackedStruct [−][src]
pub trait PackedStruct where
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]
Associated Types
Required methods
fn pack(&self) -> PackingResult<Self::ByteArray>
fn pack(&self) -> PackingResult<Self::ByteArray>
Packs the structure into a byte array.
fn unpack(src: &Self::ByteArray) -> PackingResult<Self>
fn unpack(src: &Self::ByteArray) -> PackingResult<Self>
Unpacks the structure from a byte array.