1use std::ops::Deref;
2
3use super::{
4 backend::r#trait::Backend, conn_pool::SingleUseConnectionPool, db_pool::ReusableConnectionPool,
5};
6
7pub enum PoolWrapper<B: Backend> {
9 Pool(B::Pool),
11 ReusablePool(ReusableConnectionPool<'static, B>),
13 SingleUsePool(SingleUseConnectionPool<B>),
15}
16
17impl<B: Backend> Deref for PoolWrapper<B> {
18 type Target = B::Pool;
19
20 fn deref(&self) -> &Self::Target {
21 match self {
22 Self::Pool(pool) => pool,
23 Self::ReusablePool(pool) => pool,
24 Self::SingleUsePool(pool) => pool,
25 }
26 }
27}
28
29impl<B: Backend> From<ReusableConnectionPool<'static, B>> for PoolWrapper<B> {
30 fn from(value: ReusableConnectionPool<'static, B>) -> Self {
31 Self::ReusablePool(value)
32 }
33}
34
35impl<B: Backend> From<SingleUseConnectionPool<B>> for PoolWrapper<B> {
36 fn from(value: SingleUseConnectionPool<B>) -> Self {
37 Self::SingleUsePool(value)
38 }
39}