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
use serde::{Deserialize, Serialize};
use time::{Duration, OffsetDateTime};
use tsproto_types::crypto::EccKeyPubP256;
use crate::data::{
Channel, ChannelGroup, Client, Connection, ConnectionClientData, ConnectionServerData,
OptionalChannelData, OptionalClientData, OptionalServerData, Server, ServerGroup,
};
use crate::*;
include!(concat!(env!("OUT_DIR"), "/events.rs"));
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct ExtraInfo {
pub reason: Option<Reason>,
}
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub enum Event {
PropertyAdded { id: PropertyId, invoker: Option<Invoker>, extra: ExtraInfo },
PropertyChanged {
id: PropertyId,
old: PropertyValue,
invoker: Option<Invoker>,
extra: ExtraInfo,
},
PropertyRemoved {
id: PropertyId,
old: PropertyValue,
invoker: Option<Invoker>,
extra: ExtraInfo,
},
Message {
target: MessageTarget,
invoker: Invoker,
message: String,
},
}
impl Event {
pub fn get_invoker(&self) -> Option<&Invoker> {
match self {
Event::PropertyAdded { invoker, .. }
| Event::PropertyChanged { invoker, .. }
| Event::PropertyRemoved { invoker, .. } => invoker.as_ref(),
Event::Message { invoker, .. } => Some(invoker),
}
}
}