From 65d6b147d9c78291fce67bb5f76cde0be4048dfc Mon Sep 17 00:00:00 2001 From: Awiteb Date: Wed, 10 Jul 2024 20:24:47 +0300 Subject: [PATCH] chore: Returns database connection as `Arc` Signed-off-by: Awiteb --- crates/oxidetalis/src/extensions.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/oxidetalis/src/extensions.rs b/crates/oxidetalis/src/extensions.rs index eeee250..f0fa891 100644 --- a/crates/oxidetalis/src/extensions.rs +++ b/crates/oxidetalis/src/extensions.rs @@ -31,7 +31,7 @@ use crate::{ /// Extension trait for the Depot. pub trait DepotExt { /// Returns the database connection - fn db_conn(&self) -> &DatabaseConnection; + fn db_conn(&self) -> Arc; /// Returns the server configuration fn config(&self) -> &Config; /// Retutns the nonce cache @@ -57,9 +57,11 @@ pub trait OnlineUsersExt { } impl DepotExt for Depot { - fn db_conn(&self) -> &DatabaseConnection { - self.obtain::>() - .expect("Database connection not found") + fn db_conn(&self) -> Arc { + Arc::clone( + self.obtain::>() + .expect("Database connection not found"), + ) } fn config(&self) -> &Config {