use std::collections::HashMap;
use async_trait::async_trait;
use crate::document::*;
use crate::error::Result;
#[async_trait]
pub trait Adapter: Send + Sync {
async fn info(&self) -> Result<DbInfo>;
async fn get(&self, id: &str, opts: GetOptions) -> Result<crate::document::Document>;
async fn bulk_docs(
&self,
docs: Vec<crate::document::Document>,
opts: BulkDocsOptions,
) -> Result<Vec<DocResult>>;
async fn all_docs(&self, opts: AllDocsOptions) -> Result<AllDocsResponse>;
async fn changes(&self, opts: ChangesOptions) -> Result<ChangesResponse>;
async fn revs_diff(&self, revs: HashMap<String, Vec<String>>) -> Result<RevsDiffResponse>;
async fn bulk_get(&self, docs: Vec<BulkGetItem>) -> Result<BulkGetResponse>;
async fn put_attachment(
&self,
doc_id: &str,
att_id: &str,
rev: &str,
data: Vec<u8>,
content_type: &str,
) -> Result<DocResult>;
async fn get_attachment(
&self,
doc_id: &str,
att_id: &str,
opts: GetAttachmentOptions,
) -> Result<Vec<u8>>;
async fn remove_attachment(&self, doc_id: &str, att_id: &str, rev: &str) -> Result<DocResult>;
async fn get_local(&self, id: &str) -> Result<serde_json::Value>;
async fn put_local(&self, id: &str, doc: serde_json::Value) -> Result<()>;
async fn remove_local(&self, id: &str) -> Result<()>;
async fn compact(&self) -> Result<()>;
async fn destroy(&self) -> Result<()>;
async fn close(&self) -> Result<()> {
Ok(())
}
async fn purge(
&self,
_req: HashMap<String, Vec<String>>,
) -> Result<crate::document::PurgeResponse> {
Err(crate::error::RouchError::BadRequest(
"purge not supported".into(),
))
}
async fn get_security(&self) -> Result<crate::document::SecurityDocument> {
Ok(crate::document::SecurityDocument::default())
}
async fn put_security(&self, _doc: crate::document::SecurityDocument) -> Result<()> {
Ok(())
}
}