use crate::dispatcher::{CALLBACKS, Status};
pub struct SubscriptionHandle {
pub(crate) id: u64,
}
impl SubscriptionHandle {
pub fn pause(&self) {
if let Some(mut subscriber) = CALLBACKS.get_mut(&self.id) {
subscriber.status = Status::Paused;
}
}
pub fn resume(&self) {
if let Some(mut subscriber) = CALLBACKS.get_mut(&self.id) {
subscriber.status = Status::Active;
}
}
pub fn unsubscribe(self) {
CALLBACKS.remove(&self.id);
}
}