sql_middleware/pool/
any_conn_wrapper.rs

1//! Backend-specific raw connection wrappers for `interact_*` helpers.
2
3#[cfg(feature = "mssql")]
4use tiberius::Client as TiberiusClient;
5#[cfg(feature = "mssql")]
6use tokio::net::TcpStream;
7#[cfg(feature = "mssql")]
8use tokio_util::compat::Compat;
9
10#[cfg(feature = "sqlite")]
11use rusqlite::Connection as SqliteConnectionType;
12
13/// Wrapper around a database connection for generic code.
14///
15/// This enum allows code to handle `PostgreSQL`, `SQLite`, SQL Server, or `LibSQL`
16/// connections in a generic way. It is primarily used by the `interact_*` helpers
17/// to hand raw driver connections to user closures without exposing pool internals.
18pub enum AnyConnWrapper<'a> {
19    /// `PostgreSQL` client connection
20    #[cfg(feature = "postgres")]
21    Postgres(&'a mut tokio_postgres::Client),
22    /// `SQLite` database connection
23    #[cfg(feature = "sqlite")]
24    Sqlite(&'a mut SqliteConnectionType),
25    /// SQL Server client connection
26    #[cfg(feature = "mssql")]
27    Mssql(&'a mut TiberiusClient<Compat<TcpStream>>),
28    /// `LibSQL` database connection
29    #[cfg(feature = "libsql")]
30    Libsql(&'a deadpool_libsql::Object),
31    /// Turso database connection
32    #[cfg(feature = "turso")]
33    Turso(&'a turso::Connection),
34}