pub trait KvStore: Send + Sync {
// Required methods
fn get(&self, key: &str) -> Result<Option<Vec<u8>>>;
fn put(&self, key: &str, value: &[u8]) -> Result<()>;
fn delete(&self, key: &str) -> Result<bool>;
}Expand description
Generic byte-oriented key-value store.
Sync by design — SQLite is synchronous, and local-disk calls inside an async
context are acceptable. The trait is object-safe, so a cache or session
store can hold a Box<dyn KvStore> / Arc<dyn KvStore>.
Required Methods§
Sourcefn get(&self, key: &str) -> Result<Option<Vec<u8>>>
fn get(&self, key: &str) -> Result<Option<Vec<u8>>>
Fetch the value for key, or None if it is absent.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".