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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::{Bus, Message};
use async_trait::async_trait;

pub trait Handler<M: Message>: Send + Sync {
    fn handle(&self, msg: M, bus: &Bus) -> anyhow::Result<()>;
    fn sync(&self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

#[async_trait]
pub trait AsyncHandler<M: Message>: Send + Sync {
    async fn handle(&self, msg: M, bus: &Bus) -> anyhow::Result<()>;
    async fn sync(&self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

pub trait SynchronizedHandler<M: Message>: Send {
    fn handle(&mut self, msg: M, bus: &Bus) -> anyhow::Result<()>;
    fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

#[async_trait]
pub trait AsyncSynchronizedHandler<M: Message>: Send {
    async fn handle(&mut self, msg: M, bus: &Bus) -> anyhow::Result<()>;
    async fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

pub trait BatchHandler<M: Message>: Send + Sync {
    fn handle(&self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    fn sync(&self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

#[async_trait]
pub trait AsyncBatchHandler<M: Message>: Send + Sync {
    async fn handle(&self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    async fn sync(&self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

pub trait BatchSynchronizedHandler<M: Message>: Send {
    fn handle(&mut self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

#[async_trait]
pub trait AsyncBatchSynchronizedHandler<M: Message>: Send {
    async fn handle(&mut self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    async fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

pub trait LocalHandler<M: Message> {
    fn handle(&mut self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

#[async_trait]
pub trait LocalAsyncHandler<M: Message> {
    async fn handle(&mut self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    async fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

pub trait LocalBatchHandler<M: Message> {
    fn handle(&mut self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}

#[async_trait]
pub trait LocalAsyncBatchHandler<M: Message> {
    async fn handle(&mut self, msg: Vec<M>, bus: &Bus) -> anyhow::Result<()>;
    async fn sync(&mut self, _bus: &Bus) -> anyhow::Result<()> {
        Ok(())
    }
}