I8Packer

Trait I8Packer 

Source
pub trait I8Packer {
    // Required methods
    fn pack_i8(first: i8, second: i8) -> Self;
    fn unpack_i8(&self) -> (i8, i8);
}
Expand description

Trait for packing and unpacking two i8 values into a single value.

Required Methods§

Source

fn pack_i8(first: i8, second: i8) -> Self

Packs two i8 values into a single value of the implementing type.

§Example
use num_packer::I8Packer;
let packed = u16::pack_i8(-100, 55);
assert_eq!(packed, ((-100i8 as u8 as u16) << 8) + (55u8 as u16));
Source

fn unpack_i8(&self) -> (i8, i8)

Unpacks the single value back into two i8 values.

§Example
use num_packer::I8Packer;
let packed = u16::pack_i8(-100, 55);
let (first, second) = packed.unpack_i8();
assert_eq!((first, second), (-100, 55));

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 I8Packer for i16

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for i32

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for i64

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for isize

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for u16

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for u32

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for u64

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Source§

impl I8Packer for usize

Source§

fn pack_i8(first: i8, second: i8) -> Self

Source§

fn unpack_i8(&self) -> (i8, i8)

Implementors§