Skip to main content

KeyEncoder

Trait KeyEncoder 

Source
pub trait KeyEncoder {
    // Required methods
    fn encode_key(&self, key: &Value) -> Result<Vec<u8>>;
    fn decode_key(&self, bytes: &[u8]) -> Result<(Value, usize)>;
}
Expand description

Trait for ordered-binary key encoding.

Implementations must preserve lexicographic sort order in binary representation — critical for range queries to work correctly.

Required Methods§

Source

fn encode_key(&self, key: &Value) -> Result<Vec<u8>>

Encode a JSON value to ordered-binary bytes.

Source

fn decode_key(&self, bytes: &[u8]) -> Result<(Value, usize)>

Decode ordered-binary bytes back to a JSON value.

Returns (decoded value, bytes consumed).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§