pub mod client;
pub mod document;
pub mod error;
pub mod factory;
pub mod in_memory;
pub mod meta;
pub(crate) mod query_stream;
pub use client::CosmosClient;
pub use document::CosmosDocument;
pub use error::CosmosError;
pub use in_memory::InMemoryCosmos;
pub use query_stream::QueryStream;
use async_trait::async_trait;
use serde_json::Value;
#[async_trait]
pub trait CosmosBackend: Send + Sync {
async fn upsert(&self, container: &str, doc: Value) -> Result<(), CosmosError>;
async fn bulk_upsert(&self, container: &str, docs: Vec<Value>) -> Result<(), CosmosError> {
for doc in docs {
self.upsert(container, doc).await?;
}
Ok(())
}
async fn get(
&self,
container: &str,
id: &str,
partition_key: &str,
) -> Result<Option<Value>, CosmosError>;
async fn query(
&self,
container: &str,
sql: &str,
params: Vec<(String, Value)>,
) -> Result<QueryStream, CosmosError>;
}