use async_trait::async_trait;
use crate::{
Batch, BatchResult, Capabilities, CollectionName, DeleteOptions, Key, Namespace, ReadOptions,
Result, ScanOptions, StoredValue, WriteOptions,
};
#[async_trait]
pub trait Driver: Send + Sync {
fn name(&self) -> &'static str;
fn capabilities(&self) -> Capabilities;
async fn initialise(&self) -> Result<()>;
async fn finalise(&self) -> Result<()>;
async fn get(
&self,
namespace: &Namespace,
collection: &CollectionName,
key: &Key,
options: &ReadOptions,
) -> Result<Option<StoredValue>>;
async fn set(
&self,
namespace: &Namespace,
collection: &CollectionName,
key: &Key,
value: StoredValue,
options: &WriteOptions,
) -> Result<()>;
async fn delete(
&self,
namespace: &Namespace,
collection: &CollectionName,
key: &Key,
options: &DeleteOptions,
) -> Result<bool>;
async fn exists(
&self,
namespace: &Namespace,
collection: &CollectionName,
key: &Key,
) -> Result<bool>;
async fn scan_prefix(
&self,
namespace: &Namespace,
collection: &CollectionName,
options: &ScanOptions,
) -> Result<Vec<(Key, StoredValue)>>;
async fn batch(&self, batch: Batch) -> Result<BatchResult>;
}