Trait Storable

Source
pub trait Storable<W: Word>: Sized + Copy {
    // Required methods
    fn into_word(self) -> W;
    fn from_word(word: W) -> Self;
}
Expand description

A trait that defines a bidirectional, lossless conversion between a user-facing element type T and its storage representation W.

This trait is central to FixedVec’s ability to store various integer types in a generic bit buffer.

Required Methods§

Source

fn into_word(self) -> W

Converts the element into its storage word representation.

For signed integers, this conversion uses ZigZag encoding to map negative and positive values to a compact unsigned representation.

Source

fn from_word(word: W) -> Self

Converts a storage word representation back into an element.

For signed integers, this reverses the ZigZag encoding.

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<W> Storable<W> for i8

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for i16

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for i32

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for i64

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for i128

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for isize

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for u8
where W: Word + TryFrom<u8> + TryInto<u8>,

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for u16
where W: Word + TryFrom<u16> + TryInto<u16>,

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for u32
where W: Word + TryFrom<u32> + TryInto<u32>,

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for u64
where W: Word + TryFrom<u64> + TryInto<u64>,

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for u128
where W: Word + TryFrom<u128> + TryInto<u128>,

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Source§

impl<W> Storable<W> for usize
where W: Word + TryFrom<usize> + TryInto<usize>,

Source§

fn into_word(self) -> W

Source§

fn from_word(word: W) -> Self

Implementors§