Skip to main content

SortKey

Trait SortKey 

Source
pub trait SortKey: Sized {
    // Required methods
    fn encode_sort_key(&self, output: &mut TupleOutput);
    fn decode_sort_key(input: &mut TupleInput) -> Result<Self>;
}
Expand description

Trait for types whose values can be encoded to and decoded from a sort-preserving byte representation.

The encoded bytes must satisfy: for any two values a and b of the same type, encode(a) < encode(b) (lexicographically) if and only if a < b.

Implementations must be consistent with Ord for the type.

Required Methods§

Source

fn encode_sort_key(&self, output: &mut TupleOutput)

Writes the sort-preserving encoding of self into output.

Source

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Reads a value from input that was written by encode_sort_key.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl SortKey for String

String keys are encoded as null-escaped UTF-8 followed by [0x00, 0x00]. Embedded 0x00 bytes are escaped as [0x00, 0x01]. Lexicographic byte order of encoded strings matches lexicographic string order.

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for Vec<u8>

Vec<u8> keys are encoded as null-escaped raw bytes followed by [0x00, 0x00]. Embedded 0x00 bytes are escaped as [0x00, 0x01]. Lexicographic byte order of encoded Vec<u8> values matches lexicographic byte-slice order.

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for bool

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for f32

f32 keys use the sort-preserving IEEE 754 encoding: negative values have all bits flipped; positive values have only the sign bit flipped. This ensures the full float range sorts correctly as unsigned bytes.

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for f64

f64 keys use the sort-preserving IEEE 754 encoding: negative values have all bits flipped; positive values have only the sign bit flipped.

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for i8

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for i16

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for i32

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for i64

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for u8

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for u16

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for u32

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Source§

impl SortKey for u64

Source§

fn encode_sort_key(&self, output: &mut TupleOutput)

Source§

fn decode_sort_key(input: &mut TupleInput) -> Result<Self>

Implementors§