docbox_management/
database.rs1pub use docbox_database::*;
3
4pub trait DatabaseProvider: Send + Sync + 'static {
9 fn connect(&self, database: &str) -> impl Future<Output = DbResult<DbPool>> + Send;
11}
12
13pub struct CloseOnDrop(DbPool);
14
15pub fn close_pool_on_drop(pool: &DbPool) -> CloseOnDrop {
16 CloseOnDrop(pool.clone())
17}
18
19impl Drop for CloseOnDrop {
20 fn drop(&mut self) {
21 let pool = self.0.clone();
22
23 tokio::spawn(async move {
24 tracing::debug!("closing dropped pool");
25 pool.close().await;
26 tracing::debug!("closed dropped pool");
27 });
28 }
29}