Skip to main content

Comparator

Trait Comparator 

Source
pub trait Comparator {
    const IDENTITY: [u8; 16];

    // Required method
    fn compare(&self, left: &[u8], right: &[u8]) -> Result<Ordering, Error>;
}
Expand description

A deterministic total order over encoded keys.

IDENTITY must change when ordering or accepted key encoding changes. Equal keys must have identical encodings. The comparator must be immutable and return InvalidKey for malformed keys, including compare(key, key). Persisted comparator code itself remains an application responsibility.

Required Associated Constants§

Source

const IDENTITY: [u8; 16]

Stable identity of the encoding and ordering contract.

Required Methods§

Source

fn compare(&self, left: &[u8], right: &[u8]) -> Result<Ordering, Error>

Compare two encoded keys, rejecting invalid encodings.

§Errors

Returns Error::InvalidKey when an encoded key is invalid.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§