Trait IntKey

Source
pub trait IntKey: Sized + Copy {
    type Buf: AsRef<[u8]> + AsMut<[u8]> + Into<Vec<u8>> + Default;

    // Required methods
    fn to_cw_bytes(&self) -> Self::Buf;
    fn from_cw_bytes(bytes: Self::Buf) -> Self;
}
Expand description

Our int keys are simply the big-endian representation bytes for unsigned ints, but “sign-flipped” (xored msb) big-endian bytes for signed ints.

So that the representation of signed integers is in the right lexicographical order.

Required Associated Types§

Source

type Buf: AsRef<[u8]> + AsMut<[u8]> + Into<Vec<u8>> + Default

Required Methods§

Source

fn to_cw_bytes(&self) -> Self::Buf

Source

fn from_cw_bytes(bytes: Self::Buf) -> Self

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 IntKey for i8

Source§

type Buf = [u8; 1]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for i16

Source§

type Buf = [u8; 2]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for i32

Source§

type Buf = [u8; 4]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for i64

Source§

type Buf = [u8; 8]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for i128

Source§

type Buf = [u8; 16]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for u8

Source§

type Buf = [u8; 1]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for u16

Source§

type Buf = [u8; 2]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for u32

Source§

type Buf = [u8; 4]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for u64

Source§

type Buf = [u8; 8]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Source§

impl IntKey for u128

Source§

type Buf = [u8; 16]

Source§

fn to_cw_bytes(&self) -> Self::Buf

Source§

fn from_cw_bytes(bytes: Self::Buf) -> Self

Implementors§