use sqlx::sqlite::SqlitePool; use crate::{ boot::app::Boot, channel::app::Channels, event::{self, app::Events}, message::app::Messages, setup::app::Setup, token::{self, app::Tokens}, }; #[cfg(test)] use crate::login::app::Logins; #[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 channels(&self) -> Channels { Channels::new(&self.db, &self.events) } pub const fn events(&self) -> Events { Events::new(&self.db, &self.events) } #[cfg(test)] pub const fn logins(&self) -> Logins { Logins::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) } }