1 2 3 4 5 6 7 8 9 10 11 12 13
use tokio::task::JoinHandle; pub struct SubscriptionHandle { pub task: JoinHandle<()>, pub unsub_fn: Box<dyn Fn() + Send>, } impl SubscriptionHandle { pub async fn shutdown(self) { (self.unsub_fn)(); self.task.abort(); } }