Skip to main content

KeyEncode

Trait KeyEncode 

Source
pub trait KeyEncode {
    // Required method
    fn encode_into(&self, out: &mut Vec<u8>);

    // Provided method
    fn encode(&self) -> Vec<u8>  { ... }
}
Expand description

A type that can be encoded into an order-preserving byte key.

Implementors MUST satisfy the ordering law a < b ⟺ encode(a) < encode(b) and MUST produce a self-delimiting encoding (so tuples compose). Both properties are checked by the proptests in this module for every built-in.

Required Methods§

Source

fn encode_into(&self, out: &mut Vec<u8>)

Append this value’s order-preserving encoding to out.

Provided Methods§

Source

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

Convenience: encode into a fresh Vec.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl KeyEncode for &str

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Source§

impl KeyEncode for String

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Source§

impl KeyEncode for i64

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Source§

impl KeyEncode for str

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Source§

impl KeyEncode for u64

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Source§

impl<A: KeyEncode, B: KeyEncode, C: KeyEncode> KeyEncode for (A, B, C)

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Source§

impl<A: KeyEncode, B: KeyEncode> KeyEncode for (A, B)

Source§

fn encode_into(&self, out: &mut Vec<u8>)

Implementors§