use super::*;
use crate::request::{MultiSearch, ScrollCursor, ScrollSearch};
use serde::Serialize;
#[derive(Debug, thiserror::Error)]
pub enum AdapterError {
#[error("Internal Adapter Error: {0}")]
Internal(String),
#[error("Document not found")]
NotFound,
}
#[async_trait::async_trait]
pub trait ClientAdapter: private::SealedClientAdapter {
type Transport;
fn try_new_from(settings: &Settings) -> Result<Self, AdapterError>;
fn borrow_transport(&self) -> &Self::Transport;
async fn get_by_id(&self, id: &str) -> Result<String, AdapterError>;
async fn search<B: Serialize + Sync>(&self, body: &B) -> Result<String, AdapterError>;
async fn multi_search<'a>(&self, mut searches: MultiSearch<'a>)
-> Result<String, AdapterError>;
async fn scroll_search<'a>(&self, search: ScrollSearch<'a>) -> Result<String, AdapterError>;
async fn scroll(&self, cursor: &ScrollCursor) -> Result<String, AdapterError>;
}
mod private {
pub trait SealedClientAdapter: Send + Sync + Sized {}
#[cfg(feature = "official_client")]
use crate::client::official_adapter::ElasticsearchAdapter;
#[cfg(feature = "official_client")]
impl SealedClientAdapter for ElasticsearchAdapter {}
}