Skip to main content

KeyComparator

Trait KeyComparator 

Source
pub trait KeyComparator: Send + Sync {
    // Required method
    fn compare(&self, key1: &[u8], key2: &[u8]) -> Ordering;
}
Expand description

Trait for custom key comparison.

Allows databases to use application-specific ordering rather than the default unsigned byte-by-byte comparison.

Required Methods§

Source

fn compare(&self, key1: &[u8], key2: &[u8]) -> Ordering

Compares two keys and returns their ordering.

§Arguments
  • key1 - First key to compare
  • key2 - Second key to compare
§Returns

Ordering::Less if key1 < key2, Ordering::Equal if equal, Ordering::Greater if key1 > key2

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§