sql_middleware/pool/
types.rs1#[cfg(feature = "postgres")]
2use crate::postgres::typed::PgManager;
3#[cfg(feature = "postgres")]
4use bb8::Pool as PostgresPool;
5
6#[cfg(feature = "sqlite")]
7use crate::sqlite::config::SqliteManager;
8#[cfg(feature = "sqlite")]
9use bb8::Pool as Bb8SqlitePool;
10
11#[cfg(feature = "mssql")]
12use bb8::Pool as Bb8MssqlPool;
13#[cfg(feature = "mssql")]
14use bb8_tiberius::ConnectionManager;
15
16#[cfg(feature = "turso")]
17use crate::turso::typed::TursoManager;
18#[cfg(feature = "turso")]
19use bb8::Pool as Bb8TursoPool;
20
21use crate::error::SqlMiddlewareDbError;
22
23#[derive(Clone)]
28pub enum MiddlewarePool {
29 #[cfg(feature = "postgres")]
31 Postgres(PostgresPool<PgManager>),
32 #[cfg(feature = "sqlite")]
34 Sqlite(Bb8SqlitePool<SqliteManager>),
35 #[cfg(feature = "mssql")]
37 Mssql(Bb8MssqlPool<ConnectionManager>),
38 #[cfg(feature = "turso")]
40 Turso(Bb8TursoPool<TursoManager>),
41}
42
43impl std::fmt::Debug for MiddlewarePool {
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 match self {
47 #[cfg(feature = "postgres")]
48 Self::Postgres(pool) => f.debug_tuple("Postgres").field(pool).finish(),
49 #[cfg(feature = "sqlite")]
50 Self::Sqlite(pool) => f.debug_tuple("Sqlite").field(pool).finish(),
51 #[cfg(feature = "mssql")]
52 Self::Mssql(_) => f.debug_tuple("Mssql").field(&"<TiberiusPool>").finish(),
53 #[cfg(feature = "turso")]
54 Self::Turso(pool) => f.debug_tuple("Turso").field(pool).finish(),
55 }
56 }
57}
58
59impl MiddlewarePool {
60 #[allow(clippy::unused_async)]
65 pub async fn get(&self) -> Result<&MiddlewarePool, SqlMiddlewareDbError> {
66 Ok(self)
67 }
68}