1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
use sqlx::sqlite::SqlitePool;
use crate::{
boot::app::Boot,
conversation::app::Conversations,
event::{self, app::Events},
invite::app::Invites,
message::app::Messages,
setup::app::Setup,
token::{self, app::Tokens},
};
#[cfg(test)]
use crate::user::app::Users;
#[derive(Clone)]
pub struct App {
db: SqlitePool,
events: event::Broadcaster,
token_events: token::Broadcaster,
}
impl App {
pub fn from(db: SqlitePool) -> Self {
let events = event::Broadcaster::default();
let token_events = token::Broadcaster::default();
Self {
db,
events,
token_events,
}
}
}
impl App {
pub const fn boot(&self) -> Boot {
Boot::new(&self.db)
}
pub const fn conversations(&self) -> Conversations {
Conversations::new(&self.db, &self.events)
}
pub const fn events(&self) -> Events {
Events::new(&self.db, &self.events)
}
pub const fn invites(&self) -> Invites {
Invites::new(&self.db, &self.events)
}
#[cfg(test)]
pub const fn users(&self) -> Users {
Users::new(&self.db, &self.events)
}
pub const fn messages(&self) -> Messages {
Messages::new(&self.db, &self.events)
}
pub const fn setup(&self) -> Setup {
Setup::new(&self.db, &self.events)
}
pub const fn tokens(&self) -> Tokens {
Tokens::new(&self.db, &self.token_events)
}
}
|