Skip to main content

Key

Trait Key 

Source
pub trait Key {
    // Required method
    fn to_bytes(&self) -> Vec<u8> ;
}
Expand description

Trait represent [Art] key. Trait define method which convert key into byte comparable sequence. This sequence will be used to order keys inside tree.

Required Methods§

Source

fn to_bytes(&self) -> Vec<u8>

Converts key to byte comparable sequence. This sequence used to represent key inside [Art] tree.

§Warning

Implementation must ensure that returned bytes vector have consistent order of bytes. E.g. key type must have same ordering guarantees as returned byte sequence.
For instance, if "abc" < "def", then "abc".to_bytes() < "def".to_bytes(). Violation of this rule is undefined behaviour and can cause panic.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Key for i8

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for i16

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for i32

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for i64

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for i128

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for u8

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for u16

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for u32

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for u64

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for u128

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

impl Key for usize

Source§

fn to_bytes(&self) -> Vec<u8>

Implementors§