PackedStruct

Trait PackedStruct 

Source
pub trait PackedStruct
where 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§

Source

type ByteArray: ByteArray

The appropriately sized byte array into which this structure will be packed, for example [u8; 2].

Required Methods§

Source

fn pack(&self) -> PackingResult<Self::ByteArray>

Packs the structure into a byte array.

Source

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.

Implementations on Foreign Types§

Source§

impl PackedStruct for bool

Source§

impl PackedStruct for i8

Source§

impl PackedStruct for u8

Source§

impl PackedStruct for ()

Source§

impl<const N: usize> PackedStruct for [u8; N]

Implementors§