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 turso::Database as TursoDatabase;
18
19use crate::error::SqlMiddlewareDbError;
20
21#[derive(Clone)]
26pub enum MiddlewarePool {
27 #[cfg(feature = "postgres")]
29 Postgres(PostgresPool<PgManager>),
30 #[cfg(feature = "sqlite")]
32 Sqlite(Bb8SqlitePool<SqliteManager>),
33 #[cfg(feature = "mssql")]
35 Mssql(Bb8MssqlPool<ConnectionManager>),
36 #[cfg(feature = "turso")]
38 Turso(TursoDatabase),
39}
40
41impl std::fmt::Debug for MiddlewarePool {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 match self {
45 #[cfg(feature = "postgres")]
46 Self::Postgres(pool) => f.debug_tuple("Postgres").field(pool).finish(),
47 #[cfg(feature = "sqlite")]
48 Self::Sqlite(pool) => f.debug_tuple("Sqlite").field(pool).finish(),
49 #[cfg(feature = "mssql")]
50 Self::Mssql(_) => f.debug_tuple("Mssql").field(&"<TiberiusPool>").finish(),
51 #[cfg(feature = "turso")]
52 Self::Turso(_) => f.debug_tuple("Turso").field(&"<Database>").finish(),
53 }
54 }
55}
56
57impl MiddlewarePool {
58 #[allow(clippy::unused_async)]
63 pub async fn get(&self) -> Result<&MiddlewarePool, SqlMiddlewareDbError> {
64 Ok(self)
65 }
66}