//! Async trait for key-value storage use crate::error::Result; #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] /// Async key-value store interface. /// /// For native (non-wasm32) backends, implementers should be `Send + Sync` to support runtime-agnostic async usage. /// For WASM (wasm32) backends, `Send + Sync` is not required and types may not implement them. /// /// Methods: /// - get /// - set /// - remove (was delete) /// - contains_key (was exists) /// - keys /// - clear /// Async key-value store interface for both native and WASM backends. /// /// For native (non-wasm32) backends, implementers should be `Send + Sync` to support async usage. /// For WASM (wasm32) backends, `Send + Sync` is not required. #[async_trait::async_trait] pub trait KVStore { async fn get(&self, key: &str) -> Result>>; async fn set(&self, key: &str, value: &[u8]) -> Result<()>; async fn remove(&self, key: &str) -> Result<()>; async fn contains_key(&self, key: &str) -> Result; async fn keys(&self) -> Result>; async fn clear(&self) -> Result<()>; }