Trait obkv::Key

source ·
pub trait Key: Copy {
    type BYTES: AsRef<[u8]> + for<'a> TryFrom<&'a [u8]>;

    const BYTES_SIZE: usize;

    // Required methods
    fn to_be_bytes(&self) -> Self::BYTES;
    fn from_be_bytes(array: Self::BYTES) -> Self;
}
Expand description

A trait that represents a key, this key will be encoded to disk.

Required Associated Types§

source

type BYTES: AsRef<[u8]> + for<'a> TryFrom<&'a [u8]>

The array that will contain the bytes of the key.

Required Associated Constants§

source

const BYTES_SIZE: usize

The number of bytes the BYTES array contains.

Required Methods§

source

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

Returns an array of the key bytes in big-endian.

source

fn from_be_bytes(array: Self::BYTES) -> Self

Returns the key that corresponds to the given bytes array.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Key for u8

source§

const BYTES_SIZE: usize = 1usize

§

type BYTES = [u8; 1]

source§

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

source§

fn from_be_bytes(array: Self::BYTES) -> Self

source§

impl Key for u16

source§

const BYTES_SIZE: usize = 2usize

§

type BYTES = [u8; 2]

source§

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

source§

fn from_be_bytes(array: Self::BYTES) -> Self

source§

impl Key for u32

source§

const BYTES_SIZE: usize = 4usize

§

type BYTES = [u8; 4]

source§

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

source§

fn from_be_bytes(array: Self::BYTES) -> Self

source§

impl Key for u64

source§

const BYTES_SIZE: usize = 8usize

§

type BYTES = [u8; 8]

source§

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

source§

fn from_be_bytes(array: Self::BYTES) -> Self

Implementors§