pub mod amqp;
pub mod mongo;
pub mod postgres;
pub mod rabbitmq;
#[cfg(test)]
mod tests;
use crate::value::Row;
use anyhow::Result;
use async_trait::async_trait;
#[derive(Debug, Clone)]
pub struct QueryResult {
pub columns: Vec<String>,
pub rows: Vec<Row>,
pub affected: Option<u64>,
}
#[async_trait]
pub trait DataSource: Send + Sync {
fn is_queue(&self) -> bool {
false
}
async fn list_databases(&self) -> Result<Vec<String>>;
async fn list_containers(&self, database: &str) -> Result<Vec<String>>;
async fn fetch_rows(
&self,
database: &str,
container: &str,
limit: i64,
offset: i64,
) -> Result<QueryResult>;
async fn run_query(&self, database: &str, container: &str, raw: &str) -> Result<QueryResult>;
async fn delete_row(&self, database: &str, container: &str, row: &Row) -> Result<()>;
async fn update_row(
&self,
database: &str,
container: &str,
original: &Row,
edited: &Row,
) -> Result<()>;
}