Skip to main content

KvStorageTier

Trait KvStorageTier 

Source
pub trait KvStorageTier<T>: BaseStorageTier
where T: Send + Sync + 'static,
{ // Required methods fn save(&self, key: &str, value: T) -> Result<(), StorageError>; fn load(&self, key: &str) -> Result<Option<T>, StorageError>; fn delete(&self, key: &str) -> Result<(), StorageError>; fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>; }
Expand description

Key-value tier — typed records under arbitrary string keys with codec serialization at the storage boundary. Mirrors TS KvStorageTier<T>.

Use for content-addressed caches (replay), multi-record archives (snapshot index, AI memory), and fixture stores. Snapshot is “one record”; append-log is “sequential entries”; kv is “many records, addressable by key”.

Required Methods§

Source

fn save(&self, key: &str, value: T) -> Result<(), StorageError>

Buffer a key→value mapping pending flush. Repeated save(k, _) before flush overwrites the buffered value for that key. Honors compact_every cadence.

Source

fn load(&self, key: &str) -> Result<Option<T>, StorageError>

Read the value at key. Returns Ok(None) on miss.

Source

fn delete(&self, key: &str) -> Result<(), StorageError>

Delete the value at key. Flushes through to the backend immediately (matches TS delete semantics — no debounce).

Source

fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>

Enumerate keys under prefix (lex-ASC). Delegates to StorageBackend::list via the tier’s backend.

Implementors§

Source§

impl<B, T, C> KvStorageTier<T> for KvStorage<B, T, C>
where B: StorageBackend + ?Sized, T: Send + Sync + 'static, C: Codec<T>,