pub trait StorageBackend: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn read(&self, key: &str) -> Result<Option<Vec<u8>>, StorageError>;
fn write(&self, key: &str, bytes: &[u8]) -> Result<(), StorageError>;
// Provided methods
fn delete(&self, key: &str) -> Result<(), StorageError> { ... }
fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError> { ... }
fn flush(&self) -> Result<(), StorageError> { ... }
}Expand description
Bytes-level kv backend. Tiers layer typed serialization on top via
Codec.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Diagnostic name (e.g. "memory", "file:./checkpoints"). Surfaces
in error messages and tier Display impls.
Provided Methods§
Sourcefn delete(&self, key: &str) -> Result<(), StorageError>
fn delete(&self, key: &str) -> Result<(), StorageError>
Optional delete-by-key. Default is no-op so append-only or read-only backends can stay quiet.
Sourcefn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>
fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>
Enumerate keys matching prefix (lex-ASC). Empty prefix enumerates
all keys. Default returns BackendNoListSupport — backends that don’t
support enumeration surface the diagnostic here at first call, NOT at
attach (mirrors TS lazy-throw semantics for list_by_prefix).
Sourcefn flush(&self) -> Result<(), StorageError>
fn flush(&self) -> Result<(), StorageError>
Optional drain hook — adapter authors implement when buffering writes.
Default no-op; tier flush() does NOT cascade into this by default
(the tier owns its own buffer; backend buffering is a separate concern
the backend author opts into).