1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::{MultiSender, SingleSender};

pub trait Supervisor<T>: Send + 'static {
    fn notify(self, result: T);
}

impl<T: Send + 'static> Supervisor<T> for MultiSender<T> {
    fn notify(self, result: T) {
        self.send(result);
    }
}

impl<T: Send + 'static> Supervisor<T> for SingleSender<T> {
    fn notify(mut self, result: T) {
        self.send(result);
    }
}

impl<T> Supervisor<T> for () {
    fn notify(self, _: T) {}
}

impl<T: Send + 'static> Supervisor<T> for std::sync::mpsc::Sender<T> {
    fn notify(self, result: T) {
        let _ = self.send(result);
    }
}

impl<T: Send + 'static> Supervisor<T> for tokio::sync::mpsc::Sender<T> {
    fn notify(self, result: T) {
        let _ = self.send(result);
    }
}

impl<T: Send + 'static> Supervisor<T> for tokio::sync::oneshot::Sender<T> {
    fn notify(self, result: T) {
        let _ = self.send(result);
    }
}

impl<T: Send + Sync + 'static> Supervisor<T> for tokio::sync::watch::Sender<T> {
    fn notify(self, result: T) {
        let _ = self.send(result);
    }
}

impl<T: Send + 'static> Supervisor<T> for tokio::sync::broadcast::Sender<T> {
    fn notify(self, result: T) {
        let _ = self.send(result);
    }
}