hypercall_db/traits/
push.rs1use anyhow::Result;
7use async_trait::async_trait;
8
9use crate::{PushSubscriptionRecord, UpsertPushSubscriptionInput};
10
11#[async_trait]
13pub trait PushSubscriptionReader: Send + Sync {
14 async fn get_push_subscriptions(&self, wallet: &str) -> Result<Vec<PushSubscriptionRecord>>;
16
17 async fn count_push_subscriptions(&self, wallet: &str) -> Result<i64>;
19
20 async fn push_subscription_exists(&self, wallet: &str, endpoint: &str) -> Result<bool>;
22}
23
24#[async_trait]
26pub trait PushSubscriptionWriter: PushSubscriptionReader {
27 async fn upsert_push_subscription(
30 &self,
31 input: UpsertPushSubscriptionInput,
32 ) -> Result<PushSubscriptionRecord>;
33
34 async fn update_push_preferences(
37 &self,
38 wallet: &str,
39 endpoint: &str,
40 preferences: serde_json::Value,
41 ) -> Result<bool>;
42
43 async fn delete_push_subscription(&self, wallet: &str, endpoint: &str) -> Result<bool>;
46
47 async fn delete_push_subscription_by_id(&self, id: i64) -> Result<bool>;
49}