diff options
Diffstat (limited to 'src/app.rs')
| -rw-r--r-- | src/app.rs | 79 |
1 files changed, 61 insertions, 18 deletions
@@ -1,3 +1,4 @@ +use axum::extract::FromRef; use sqlx::sqlite::SqlitePool; #[cfg(test)] @@ -33,40 +34,82 @@ impl App { } impl App { - pub const fn boot(&self) -> Boot<'_> { - Boot::new(&self.db) + pub fn boot(&self) -> Boot { + Boot::new(self.db.clone()) } - pub const fn conversations(&self) -> Conversations<'_> { - Conversations::new(&self.db, &self.events) + pub fn conversations(&self) -> Conversations { + Conversations::new(self.db.clone(), self.events.clone()) } - pub const fn events(&self) -> Events<'_> { - Events::new(&self.db, &self.events) + pub fn events(&self) -> Events { + Events::new(self.db.clone(), self.events.clone()) } - pub const fn invites(&self) -> Invites<'_> { - Invites::new(&self.db, &self.events) + pub fn invites(&self) -> Invites { + Invites::new(self.db.clone(), self.events.clone()) } - pub const fn logins(&self) -> Logins<'_> { - Logins::new(&self.db, &self.token_events) + pub fn logins(&self) -> Logins { + Logins::new(self.db.clone(), self.token_events.clone()) } - pub const fn messages(&self) -> Messages<'_> { - Messages::new(&self.db, &self.events) + pub fn messages(&self) -> Messages { + Messages::new(self.db.clone(), self.events.clone()) } - pub const fn setup(&self) -> Setup<'_> { - Setup::new(&self.db, &self.events) + pub fn setup(&self) -> Setup { + Setup::new(self.db.clone(), self.events.clone()) } - pub const fn tokens(&self) -> Tokens<'_> { - Tokens::new(&self.db, &self.token_events) + pub fn tokens(&self) -> Tokens { + Tokens::new(self.db.clone(), self.token_events.clone()) } #[cfg(test)] - pub const fn users(&self) -> Users<'_> { - Users::new(&self.db, &self.events) + pub fn users(&self) -> Users { + Users::new(self.db.clone(), self.events.clone()) + } +} + +impl FromRef<App> for Boot { + fn from_ref(app: &App) -> Self { + app.boot() + } +} + +impl FromRef<App> for Conversations { + fn from_ref(app: &App) -> Self { + app.conversations() + } +} + +impl FromRef<App> for Invites { + fn from_ref(app: &App) -> Self { + app.invites() + } +} + +impl FromRef<App> for Logins { + fn from_ref(app: &App) -> Self { + app.logins() + } +} + +impl FromRef<App> for Messages { + fn from_ref(app: &App) -> Self { + app.messages() + } +} + +impl FromRef<App> for Setup { + fn from_ref(app: &App) -> Self { + app.setup() + } +} + +impl FromRef<App> for Tokens { + fn from_ref(app: &App) -> Self { + app.tokens() } } |
