chore: Returns database connection as Arc

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-07-10 20:24:47 +03:00
parent b4b3b537fd
commit 65d6b147d9
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F

View file

@ -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<DatabaseConnection>;
/// 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 {
fn db_conn(&self) -> Arc<DatabaseConnection> {
Arc::clone(
self.obtain::<Arc<DatabaseConnection>>()
.expect("Database connection not found")
.expect("Database connection not found"),
)
}
fn config(&self) -> &Config {