summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2022-10-05 12:45:54 +0200
committerNyaaori <+@nyaaori.cat>2022-10-10 14:02:00 +0200
commitface766e0f32481fd97a435f1ed8579d8cfc634c (patch)
tree6985fdee252323a858b6ff29b825d5b48baef61a /src/lib.rs
parent8708cd3b633d88d260982563f2e2826bc8b12038 (diff)
downloadconduit-face766e0f32481fd97a435f1ed8579d8cfc634c.zip
messing with trait objects
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7239900..75cf6c7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,22 +13,16 @@ mod service;
pub mod api;
mod utils;
-use std::{cell::Cell, sync::RwLock};
+use std::{cell::Cell, sync::{RwLock, Arc}};
pub use config::Config;
pub use utils::error::{Error, Result};
pub use service::{Services, pdu::PduEvent};
pub use api::ruma_wrapper::{Ruma, RumaResponse};
-use crate::database::KeyValueDatabase;
+pub static SERVICES: RwLock<Option<Arc<Services>>> = RwLock::new(None);
-pub static SERVICES: RwLock<Option<ServicesEnum>> = RwLock::new(None);
-
-enum ServicesEnum {
- Rocksdb(Services<KeyValueDatabase>)
-}
-
-pub fn services<'a>() -> &'a Services<KeyValueDatabase> {
- &SERVICES.read().unwrap()
+pub fn services<'a>() -> Arc<Services> {
+ Arc::clone(&SERVICES.read().unwrap())
}