actr_platform_traits/
storage.rs1use std::sync::Arc;
4
5use async_trait::async_trait;
6
7use crate::PlatformError;
8
9pub enum KvOp {
11 Set { key: String, value: Vec<u8> },
12 Delete { key: String },
13}
14
15#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
20#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
21pub trait KvStore: Send + Sync {
22 async fn get(&self, key: &str) -> Result<Option<Vec<u8>>, PlatformError>;
24
25 async fn set(&self, key: &str, value: &[u8]) -> Result<(), PlatformError>;
27
28 async fn delete(&self, key: &str) -> Result<bool, PlatformError>;
30
31 async fn list_keys(&self, prefix: Option<&str>) -> Result<Vec<String>, PlatformError>;
33
34 async fn batch(&self, ops: Vec<KvOp>) -> Result<(), PlatformError>;
36}
37
38pub trait KvStoreClone: KvStore {
40 fn clone_box(&self) -> Arc<dyn KvStore>;
41}