use crate::error::Result;
use crate::types::{CipherBlob, Key};
use async_trait::async_trait;
#[async_trait]
pub trait StorageEngine: Send + Sync + 'static {
async fn put(&self, key: &Key, value: &CipherBlob) -> Result<()>;
async fn get(&self, key: &Key) -> Result<Option<CipherBlob>>;
async fn atomic_update<F>(&self, key: &Key, f: F) -> Result<()>
where
F: Fn(&CipherBlob) -> Result<CipherBlob> + Send + Sync;
async fn delete(&self, key: &Key) -> Result<()>;
async fn range(&self, start: &Key, end: &Key) -> Result<Vec<(Key, CipherBlob)>>;
async fn contains(&self, key: &Key) -> Result<bool> {
Ok(self.get(key).await?.is_some())
}
async fn keys(&self) -> Result<Vec<Key>>;
async fn flush(&self) -> Result<()>;
async fn close(&self) -> Result<()>;
}