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
use crate::Message;
use std::time::Duration;
#[derive(Debug, Eq, PartialEq)]
pub enum Event {
Retry(Duration),
Message(Message),
}
impl Event {
pub(crate) fn new_msg(name: String, data: Vec<u8>, id: Option<String>) -> Self {
Self::Message(Message { name, data, id })
}
pub(crate) fn new_retry(dur: u64) -> Self {
Self::Retry(Duration::from_secs_f64(dur as f64))
}
pub fn is_retry(&self) -> bool {
match *self {
Self::Retry(_) => true,
_ => false,
}
}
pub fn is_message(&self) -> bool {
match *self {
Self::Message(_) => true,
_ => false,
}
}
}