use crate::algebra::Expr;
use crate::schema::{ResultSet, Schema};
use crate::Result;
pub mod yottadb;
#[cfg(feature = "backend-postgres")]
pub mod postgres;
#[cfg(feature = "backend-sqlite")]
pub mod sqlite;
#[cfg(feature = "backend-mongodb")]
pub mod mongodb;
pub trait Backend {
type Connection;
type CompiledQuery;
fn compile(&self, expr: &Expr) -> Result<Self::CompiledQuery>;
fn execute(&self, conn: &mut Self::Connection, query: &Self::CompiledQuery) -> Result<ResultSet>;
fn query(&self, conn: &mut Self::Connection, expr: &Expr) -> Result<ResultSet> {
let compiled = self.compile(expr)?;
self.execute(conn, &compiled)
}
fn get_schema(&self, conn: &mut Self::Connection, relation: &str) -> Result<Schema>;
}
#[derive(Debug, Clone)]
pub struct QueryPlan {
pub algebra: String,
pub backend_native: String,
pub estimated_cost: Option<f64>,
}