Skip to main content

Encoding

Trait Encoding 

Source
pub trait Encoding: Sized {
    type Repr: AsRef<[u8]> + AsMut<[u8]> + Copy + Clone + Sized;

    const BIT_SIZE: usize;
    const BYTE_SIZE: usize;

    // Required methods
    fn from_be_bytes(bytes: Self::Repr) -> Self;
    fn from_le_bytes(bytes: Self::Repr) -> Self;
    fn to_be_bytes(&self) -> Self::Repr;
    fn to_le_bytes(&self) -> Self::Repr;
}
Expand description

Encoding support.

Required Associated Constants§

Source

const BIT_SIZE: usize

Size of this integer in bits.

Source

const BYTE_SIZE: usize

Size of this integer in bytes.

Required Associated Types§

Source

type Repr: AsRef<[u8]> + AsMut<[u8]> + Copy + Clone + Sized

Byte array representation.

Required Methods§

Source

fn from_be_bytes(bytes: Self::Repr) -> Self

Decode from big endian bytes.

Source

fn from_le_bytes(bytes: Self::Repr) -> Self

Decode from little endian bytes.

Source

fn to_be_bytes(&self) -> Self::Repr

Encode to big endian bytes.

Source

fn to_le_bytes(&self) -> Self::Repr

Encode to little endian bytes.

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.

Implementors§

Source§

impl Encoding for Limb

Source§

const BIT_SIZE: usize = Self::BIT_SIZE

Source§

const BYTE_SIZE: usize = Self::BYTE_SIZE

Source§

type Repr = [u8; 8]

Source§

impl Encoding for U64

Source§

impl Encoding for U128

Source§

impl Encoding for U192

Source§

impl Encoding for U256

Source§

impl Encoding for U384

Source§

impl Encoding for U448

Source§

impl Encoding for U512

Source§

impl Encoding for U576

Source§

impl Encoding for U768

Source§

impl Encoding for U896

Source§

impl Encoding for U1024

Source§

impl Encoding for U1536

Source§

impl Encoding for U1792

Source§

impl Encoding for U2048

Source§

impl Encoding for U3072

Source§

impl Encoding for U3584

Source§

impl Encoding for U4096

Source§

impl Encoding for U6144

Source§

impl Encoding for U8192