wb_cache/test/simulation/db/driver.rs
1//! Database drivers.
2#[cfg(feature = "pg")]
3pub mod pg;
4#[cfg(feature = "sqlite")]
5pub mod sqlite;
6
7use std::fmt::Debug;
8
9use async_trait::async_trait;
10use sea_orm::DatabaseConnection;
11
12use crate::test::simulation::types::Result;
13
14/// Trait for database [drivers](super::driver#modules) in the simulation environment.
15#[async_trait]
16pub trait DatabaseDriver: Debug + Sync + Send + 'static {
17 /// Returns the database connection for the driver.
18 fn connection(&self) -> DatabaseConnection;
19 /// Configure the database connection parameters. See corresponding driver implementation for details.
20 async fn configure(&self) -> Result<()>;
21 /// Checkpointing allows the driver to perform any necessary operations at designated points determined by the
22 /// calling code.
23 async fn checkpoint(&self) -> Result<()>;
24}