Trait BitCast

Source
pub trait BitCast: Sized {
    // Required methods
    fn to_u64(&self) -> u64;
    fn from_u64(value: u64) -> Self;
}
Expand description

All encoding and decoding is done via u64. So all types must implement this trait to be able to be encoded and decoded.

Required Methods§

Source

fn to_u64(&self) -> u64

Convert the value to a u64.

Source

fn from_u64(value: u64) -> Self

Convert a u64 to the value.

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 BitCast for bool

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for f32

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for f64

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for i8

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for i16

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for i32

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for i64

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for isize

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for u8

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for u16

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for u32

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for u64

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Source§

impl BitCast for usize

Source§

fn to_u64(&self) -> u64

Source§

fn from_u64(value: u64) -> Self

Implementors§