From 398bc79a3f1f4316e6cc33b6e6bce133c1db3e4c Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 27 Oct 2025 17:29:36 -0400 Subject: Convert the `Conversations` component into a freestanding struct. Unlike the previous example, this involves cloning an event broadcaster, as well. This is, per the documentation, how the type may be used. From : > The Sender can be cloned to send to the same channel from multiple points in the process or it can be used concurrently from an `Arc`. The language is less firm than the language sqlx uses for its pool, but the intent is clear enough, and it works in practice. --- src/app.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index e33ee39..3f3885a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -38,8 +38,8 @@ impl App { 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<'_> { @@ -77,3 +77,9 @@ impl FromRef for Boot { app.boot() } } + +impl FromRef for Conversations { + fn from_ref(app: &App) -> Self { + app.conversations() + } +} -- cgit v1.2.3