LexicographicEncoding

Trait LexicographicEncoding 

Source
pub trait LexicographicEncoding: Ord + FullCodec {
    type Encoding: AsMut<[u8]> + Ord + FullCodec;

    // Required methods
    fn lexicographic_encode(&self) -> Self::Encoding;
    fn lexicographic_decode(encoding: Self::Encoding) -> Self;
}
Expand description

A trait to obtain an encoding whose lexicographic order corresponds to the value’s.

Required Associated Types§

Source

type Encoding: AsMut<[u8]> + Ord + FullCodec

The representation of the encoding.

This SHOULD be [u8; N] or similar.

Required Methods§

Source

fn lexicographic_encode(&self) -> Self::Encoding

Encode such that cmp(e(A), e(B)) == cmp(A, B).

Source

fn lexicographic_decode(encoding: Self::Encoding) -> Self

Decode such that d(e(A)) == A.

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 LexicographicEncoding for u8

Source§

type Encoding = [u8; 1]

Source§

fn lexicographic_encode(&self) -> Self::Encoding

Source§

fn lexicographic_decode(encoding: Self::Encoding) -> Self

Source§

impl LexicographicEncoding for u16

Source§

type Encoding = [u8; 2]

Source§

fn lexicographic_encode(&self) -> Self::Encoding

Source§

fn lexicographic_decode(encoding: Self::Encoding) -> Self

Source§

impl LexicographicEncoding for u32

Source§

type Encoding = [u8; 4]

Source§

fn lexicographic_encode(&self) -> Self::Encoding

Source§

fn lexicographic_decode(encoding: Self::Encoding) -> Self

Source§

impl LexicographicEncoding for u64

Source§

type Encoding = [u8; 8]

Source§

fn lexicographic_encode(&self) -> Self::Encoding

Source§

fn lexicographic_decode(encoding: Self::Encoding) -> Self

Source§

impl LexicographicEncoding for u128

Implementors§