Skip to main content

dactyl_db/adapter/
mod.rs

1//! Adapter trait — internal to dactyl.
2//!
3//! Both `SqliteAdapter` and `NeonAdapter` live behind their respective
4//! feature gates and are reachable as `dactyl::adapter::sqlite::*` /
5//! `dactyl::adapter::neon::*`. Nothing else at the crate root re-exports
6//! the underlying types.
7
8use crate::error::DactylError;
9use crate::rows::{Parameter, Rows};
10use crate::Statement;
11
12/// Internal trait every adapter implements.
13pub trait Adapter: Send + Sync {
14    /// Execute a query against the backing datastore.
15    fn execute(
16        &self,
17        query: &str,
18        params: &[Parameter],
19        optimize: bool,
20        write: bool,
21    ) -> Result<Rows, DactylError>;
22
23    /// Execute a raw schema/DDL/migration operation.
24    fn execute_raw(&self, query: &str, params: &[Parameter]) -> Result<u64, DactylError>;
25
26    /// Execute an atomic batch of statements.
27    fn execute_batch(&self, statements: &[Statement]) -> Result<Vec<Rows>, DactylError>;
28}
29
30#[cfg(feature = "sqlite")]
31pub mod sqlite;
32
33#[cfg(feature = "neon")]
34pub mod neon;