Skip to main content

Key

Trait Key 

Source
pub trait Key: Send + Sync {
    // Required methods
    fn as_bytes(&self) -> Vec<u8> ;
    fn from_bytes(b: &[u8]) -> Result<Self, StorageError>
       where Self: Sized;
}
Expand description

User-defined typed key. Implementors define how to serialize the key to bytes for KvPut / KvDelete write ops; trait is object-safe-by-design (no generic methods).

The StoragePort trait deliberately does NOT take K: Key on scan_range / read_as_of — generic methods break Arc<dyn StoragePort> (object safety). Callers with typed keys call .as_bytes() at the call site and pass &[u8].

Required Methods§

Source

fn as_bytes(&self) -> Vec<u8>

Source

fn from_bytes(b: &[u8]) -> Result<Self, StorageError>
where Self: Sized,

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§