use crate::types::Result;
use async_trait::async_trait;
use bytes::Bytes;
#[async_trait]
pub trait MeruStore: Send + Sync + 'static {
async fn put(&self, path: &str, data: Bytes) -> Result<()>;
async fn get(&self, path: &str) -> Result<Bytes>;
async fn get_range(&self, path: &str, offset: usize, length: usize) -> Result<Bytes>;
async fn delete(&self, path: &str) -> Result<()>;
async fn exists(&self, path: &str) -> Result<bool>;
async fn list(&self, prefix: &str) -> Result<Vec<String>>;
async fn put_if_absent(&self, path: &str, data: Bytes) -> Result<()> {
if self.exists(path).await? {
return Err(crate::types::MeruError::AlreadyExists(path.into()));
}
self.put(path, data).await
}
}