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§
Sourcefn encode_sort_key(&self, output: &mut TupleOutput)
fn encode_sort_key(&self, output: &mut TupleOutput)
Writes the sort-preserving encoding of self into output.
Sourcefn decode_sort_key(input: &mut TupleInput) -> Result<Self>
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.
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.
fn encode_sort_key(&self, output: &mut TupleOutput)
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.
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.
fn encode_sort_key(&self, output: &mut TupleOutput)
fn decode_sort_key(input: &mut TupleInput) -> Result<Self>
Source§impl SortKey for bool
impl SortKey for bool
fn encode_sort_key(&self, output: &mut TupleOutput)
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.
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.
fn encode_sort_key(&self, output: &mut TupleOutput)
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.
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.