rustical_store/
subscription_store.rs

1use crate::Error;
2use async_trait::async_trait;
3use chrono::NaiveDateTime;
4
5pub struct Subscription {
6    pub id: String,
7    pub topic: String,
8    pub expiration: NaiveDateTime,
9    pub push_resource: String,
10    pub public_key: String,
11    pub public_key_type: String,
12    pub auth_secret: String,
13}
14
15#[async_trait]
16pub trait SubscriptionStore: Send + Sync + 'static {
17    async fn get_subscriptions(&self, topic: &str) -> Result<Vec<Subscription>, Error>;
18    async fn get_subscription(&self, id: &str) -> Result<Subscription, Error>;
19    /// Returns whether a subscription under the id already existed
20    async fn upsert_subscription(&self, sub: Subscription) -> Result<bool, Error>;
21    async fn delete_subscription(&self, id: &str) -> Result<(), Error>;
22}