diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-10-28 15:22:29 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-10-28 15:22:29 -0400 |
| commit | 3c588861ef5814de329743147398dbae22c1aeeb (patch) | |
| tree | 3ae5ac8d432a384fbc839b414d25f7567022ba3f | |
| parent | f866e480447746ce4958e5475d3c9e407812231f (diff) | |
Fix merge mistakes and make the `Vapid` component freestanding.
In 4a91792e023a5877f8ac9b8a352e99c4486d698f, I merged in the app component struct changes, but neglected to notice that the `app.vapid()` method had ended up attached to the wrong impl block during the merge. This fixes that.
I've also carried the change to component structs through, so `Vapid` is now a freestanding component, rather than a view of the `App` struct's internals.
| -rw-r--r-- | src/app.rs | 10 | ||||
| -rw-r--r-- | src/boot/handlers/boot/test.rs | 6 | ||||
| -rw-r--r-- | src/vapid/app.rs | 10 |
3 files changed, 16 insertions, 10 deletions
@@ -71,6 +71,10 @@ impl App { pub fn users(&self) -> Users { Users::new(self.db.clone(), self.events.clone()) } + + pub fn vapid(&self) -> Vapid { + Vapid::new(self.db.clone(), self.events.clone()) + } } impl FromRef<App> for Boot { @@ -113,8 +117,10 @@ impl FromRef<App> for Tokens { fn from_ref(app: &App) -> Self { app.tokens() } +} - pub const fn vapid(&self) -> Vapid<'_> { - Vapid::new(&self.db, &self.events) +impl FromRef<App> for Vapid { + fn from_ref(app: &App) -> Self { + app.vapid() } } diff --git a/src/boot/handlers/boot/test.rs b/src/boot/handlers/boot/test.rs index 7eb4e52..f192478 100644 --- a/src/boot/handlers/boot/test.rs +++ b/src/boot/handlers/boot/test.rs @@ -90,7 +90,7 @@ async fn includes_vapid_key() { .expect("key rotation always succeeds"); let viewer = fixtures::identity::fictitious(); - let response = super::handler(State(app), viewer) + let response = super::handler(State(app.boot()), viewer) .await .expect("boot always succeeds"); @@ -114,7 +114,7 @@ async fn includes_only_latest_vapid_key() { .expect("key rotation always succeeds"); let viewer = fixtures::identity::fictitious(); - let response = super::handler(State(app.clone()), viewer.clone()) + let response = super::handler(State(app.boot()), viewer.clone()) .await .expect("boot always succeeds"); @@ -132,7 +132,7 @@ async fn includes_only_latest_vapid_key() { .await .expect("key rotation always succeeds"); - let response = super::handler(State(app), viewer) + let response = super::handler(State(app.boot()), viewer) .await .expect("boot always succeeds"); diff --git a/src/vapid/app.rs b/src/vapid/app.rs index b6e1bc5..61523d5 100644 --- a/src/vapid/app.rs +++ b/src/vapid/app.rs @@ -8,13 +8,13 @@ use crate::{ event::{Broadcaster, Sequence, repo::Provider}, }; -pub struct Vapid<'a> { - db: &'a SqlitePool, - events: &'a Broadcaster, +pub struct Vapid { + db: SqlitePool, + events: Broadcaster, } -impl<'a> Vapid<'a> { - pub const fn new(db: &'a SqlitePool, events: &'a Broadcaster) -> Self { +impl Vapid { + pub const fn new(db: SqlitePool, events: Broadcaster) -> Self { Self { db, events } } |
