Skip to main content

lgui_store/store/
subscription.rs

1use std::{borrow::Cow, sync::Arc};
2
3#[derive(Clone, Debug)]
4pub struct StoreNotification {
5    pub store_key: &'static str,
6    pub reason: Cow<'static, str>,
7}
8
9#[derive(Clone, Debug, PartialEq, Eq, Hash)]
10pub struct SubscriptionToken(pub(crate) u64);
11
12#[derive(Clone, Debug)]
13pub struct Subscription {
14    pub store_key: &'static str,
15}
16
17impl Subscription {
18    pub fn store(store_key: &'static str) -> Self {
19        Self { store_key }
20    }
21}
22
23pub trait StoreObserver: Send + Sync {
24    fn on_store_notification(&self, notification: &StoreNotification);
25}
26
27pub type StoreObserverRef = Arc<dyn StoreObserver>;