Skip to main content

Packable4

Trait Packable4 

Source
pub trait Packable4: Copy + 'static {
    type Unpacked: Copy + Default;

    // Required methods
    fn pack_pair(low: Self, high: Self) -> u8;
    fn unpack_pair(packed: u8) -> (Self, Self);
    fn unpack_slice_packed(packed: &[u8], unpacked: &mut [Self::Unpacked]);
    fn unpack_single(element: Self) -> Self::Unpacked;
}
Expand description

Trait for 4-bit types that can be packed two per byte.

Required Associated Types§

Source

type Unpacked: Copy + Default

The unpacked representation type.

Required Methods§

Source

fn pack_pair(low: Self, high: Self) -> u8

Pack a low and high element into a single byte.

Source

fn unpack_pair(packed: u8) -> (Self, Self)

Unpack a single byte into a low and high element.

Source

fn unpack_slice_packed(packed: &[u8], unpacked: &mut [Self::Unpacked])

Unpack a slice of packed pairs to a slice of unpacked elements.

Source

fn unpack_single(element: Self) -> Self::Unpacked

Unpack a single element.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§