gamenight/backend-actix/src/util/mod.rs

11 lines
348 B
Rust

use diesel::{r2d2::{PooledConnection, ManageConnection, Pool}};
pub trait GetConnection<T> where T: ManageConnection {
fn get_conn(&self) -> PooledConnection<T>;
}
impl<T: ManageConnection> GetConnection<T> for Pool<T> {
fn get_conn(&self) -> PooledConnection<T> {
self.get().expect("Couldn't get db connection from pool")
}
}