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 = "libsql")]
17use deadpool_libsql::Pool as DeadpoolLibsqlPool;
18#[cfg(feature = "turso")]
19use turso::Database as TursoDatabase;
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 = "libsql")]
40 Libsql(DeadpoolLibsqlPool),
41 #[cfg(feature = "turso")]
43 Turso(TursoDatabase),
44}
45
46impl std::fmt::Debug for MiddlewarePool {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 match self {
50 #[cfg(feature = "postgres")]
51 Self::Postgres(pool) => f.debug_tuple("Postgres").field(pool).finish(),
52 #[cfg(feature = "sqlite")]
53 Self::Sqlite(pool) => f.debug_tuple("Sqlite").field(pool).finish(),
54 #[cfg(feature = "mssql")]
55 Self::Mssql(_) => f.debug_tuple("Mssql").field(&"<TiberiusPool>").finish(),
56 #[cfg(feature = "libsql")]
57 Self::Libsql(pool) => f.debug_tuple("Libsql").field(pool).finish(),
58 #[cfg(feature = "turso")]
59 Self::Turso(_) => f.debug_tuple("Turso").field(&"<Database>").finish(),
60 }
61 }
62}
63
64impl MiddlewarePool {
65 #[allow(clippy::unused_async)]
70 pub async fn get(&self) -> Result<&MiddlewarePool, SqlMiddlewareDbError> {
71 Ok(self)
72 }
73}