Convert [ConnectOptions] into [sqlx::pool::PoolOptions]
(self)
| 38 | impl ConnectOptions { |
| 39 | /// Convert [ConnectOptions] into [sqlx::pool::PoolOptions] |
| 40 | pub fn sqlx_pool_options<DB>(self) -> sqlx::pool::PoolOptions<DB> |
| 41 | where |
| 42 | DB: sqlx::Database, |
| 43 | { |
| 44 | let mut opt = sqlx::pool::PoolOptions::new(); |
| 45 | if let Some(max_connections) = self.max_connections { |
| 46 | opt = opt.max_connections(max_connections); |
| 47 | } |
| 48 | if let Some(min_connections) = self.min_connections { |
| 49 | opt = opt.min_connections(min_connections); |
| 50 | } |
| 51 | if let Some(connect_timeout) = self.connect_timeout { |
| 52 | opt = opt.acquire_timeout(connect_timeout); |
| 53 | } |
| 54 | if let Some(idle_timeout) = self.idle_timeout { |
| 55 | opt = opt.idle_timeout(Some(idle_timeout)); |
| 56 | } |
| 57 | if let Some(acquire_timeout) = self.acquire_timeout { |
| 58 | opt = opt.acquire_timeout(acquire_timeout); |
| 59 | } |
| 60 | if let Some(max_lifetime) = self.max_lifetime { |
| 61 | opt = opt.max_lifetime(Some(max_lifetime)); |
| 62 | } |
| 63 | opt = opt.test_before_acquire(self.test_before_acquire); |
| 64 | opt |
| 65 | } |
| 66 | } |
no test coverage detected