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 Types§

source

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

Byte array representation.

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 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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Encoding for Limb

source§

const BIT_SIZE: usize = 64usize

source§

const BYTE_SIZE: usize = 8usize

§

type Repr = [u8; 8]

source§

impl Encoding for U64

source§

const BIT_SIZE: usize = 64usize

source§

const BYTE_SIZE: usize = 8usize

§

type Repr = [u8; 8]

source§

impl Encoding for U128

source§

const BIT_SIZE: usize = 128usize

source§

const BYTE_SIZE: usize = 16usize

§

type Repr = [u8; 16]

source§

impl Encoding for U192

source§

const BIT_SIZE: usize = 192usize

source§

const BYTE_SIZE: usize = 24usize

§

type Repr = [u8; 24]

source§

impl Encoding for U256

source§

const BIT_SIZE: usize = 256usize

source§

const BYTE_SIZE: usize = 32usize

§

type Repr = [u8; 32]

source§

impl Encoding for U384

source§

const BIT_SIZE: usize = 384usize

source§

const BYTE_SIZE: usize = 48usize

§

type Repr = [u8; 48]

source§

impl Encoding for U448

source§

const BIT_SIZE: usize = 448usize

source§

const BYTE_SIZE: usize = 56usize

§

type Repr = [u8; 56]

source§

impl Encoding for U512

source§

const BIT_SIZE: usize = 512usize

source§

const BYTE_SIZE: usize = 64usize

§

type Repr = [u8; 64]

source§

impl Encoding for U576

source§

const BIT_SIZE: usize = 576usize

source§

const BYTE_SIZE: usize = 72usize

§

type Repr = [u8; 72]

source§

impl Encoding for U768

source§

const BIT_SIZE: usize = 768usize

source§

const BYTE_SIZE: usize = 96usize

§

type Repr = [u8; 96]

source§

impl Encoding for U896

source§

const BIT_SIZE: usize = 896usize

source§

const BYTE_SIZE: usize = 112usize

§

type Repr = [u8; 112]

source§

impl Encoding for U1024

source§

const BIT_SIZE: usize = 1_024usize

source§

const BYTE_SIZE: usize = 128usize

§

type Repr = [u8; 128]

source§

impl Encoding for U1536

source§

const BIT_SIZE: usize = 1_536usize

source§

const BYTE_SIZE: usize = 192usize

§

type Repr = [u8; 192]

source§

impl Encoding for U1792

source§

const BIT_SIZE: usize = 1_792usize

source§

const BYTE_SIZE: usize = 224usize

§

type Repr = [u8; 224]

source§

impl Encoding for U2048

source§

const BIT_SIZE: usize = 2_048usize

source§

const BYTE_SIZE: usize = 256usize

§

type Repr = [u8; 256]

source§

impl Encoding for U3072

source§

const BIT_SIZE: usize = 3_072usize

source§

const BYTE_SIZE: usize = 384usize

§

type Repr = [u8; 384]

source§

impl Encoding for U3584

source§

const BIT_SIZE: usize = 3_584usize

source§

const BYTE_SIZE: usize = 448usize

§

type Repr = [u8; 448]

source§

impl Encoding for U4096

source§

const BIT_SIZE: usize = 4_096usize

source§

const BYTE_SIZE: usize = 512usize

§

type Repr = [u8; 512]

source§

impl Encoding for U6144

source§

const BIT_SIZE: usize = 6_144usize

source§

const BYTE_SIZE: usize = 768usize

§

type Repr = [u8; 768]

source§

impl Encoding for U8192

source§

const BIT_SIZE: usize = 8_192usize

source§

const BYTE_SIZE: usize = 1_024usize

§

type Repr = [u8; 1024]