heed

Trait Comparator

Source
pub trait Comparator {
    // Required method
    fn compare(a: &[u8], b: &[u8]) -> Ordering;
}
Expand description

Define a custom key comparison function for a database.

The comparison function is called whenever it is necessary to compare a key specified by the application with a key currently stored in the database. If no comparison function is specified, and no special key flags were specified, the keys are compared lexically, with shorter keys collating before longer keys.

Required Methods§

Source

fn compare(a: &[u8], b: &[u8]) -> Ordering

Compares the raw bytes representation of two keys.

§Safety

This function must never crash, this is the reason why it takes raw bytes as parameter, to let you define the recovery method you want in case of a decoding error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§