sql_middleware/pool/
types.rs1#[cfg(feature = "postgres")]
2use deadpool_postgres::Pool as DeadpoolPostgresPool;
3
4#[cfg(feature = "sqlite")]
5use deadpool_sqlite::Pool as DeadpoolSqlitePool;
6
7#[cfg(feature = "sqlite")]
8pub type SqliteWritePool = DeadpoolSqlitePool;
9
10#[cfg(feature = "mssql")]
11use deadpool_tiberius::Pool as TiberiusPool;
12
13#[cfg(feature = "libsql")]
14use deadpool_libsql::Pool as DeadpoolLibsqlPool;
15#[cfg(feature = "turso")]
16use turso::Database as TursoDatabase;
17
18use crate::error::SqlMiddlewareDbError;
19
20#[derive(Clone)]
25pub enum MiddlewarePool {
26 #[cfg(feature = "postgres")]
28 Postgres(DeadpoolPostgresPool),
29 #[cfg(feature = "sqlite")]
31 Sqlite(DeadpoolSqlitePool),
32 #[cfg(feature = "mssql")]
34 Mssql(TiberiusPool),
35 #[cfg(feature = "libsql")]
37 Libsql(DeadpoolLibsqlPool),
38 #[cfg(feature = "turso")]
40 Turso(TursoDatabase),
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 = "libsql")]
54 Self::Libsql(pool) => f.debug_tuple("Libsql").field(pool).finish(),
55 #[cfg(feature = "turso")]
56 Self::Turso(_) => f.debug_tuple("Turso").field(&"<Database>").finish(),
57 }
58 }
59}
60
61impl MiddlewarePool {
62 #[allow(clippy::unused_async)]
67 pub async fn get(&self) -> Result<&MiddlewarePool, SqlMiddlewareDbError> {
68 Ok(self)
69 }
70}