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
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId};
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room_key_request", kind = ToDevice)]
pub struct RoomKeyRequestToDeviceEventContent {
pub action: Action,
pub body: Option<RequestedKeyInfo>,
pub requesting_device_id: DeviceIdBox,
pub request_id: String,
}
impl RoomKeyRequestToDeviceEventContent {
pub fn new(
action: Action,
body: Option<RequestedKeyInfo>,
requesting_device_id: DeviceIdBox,
request_id: String,
) -> Self {
Self { action, body, requesting_device_id, request_id }
}
}
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")]
pub enum Action {
Request,
#[ruma_enum(rename = "request_cancellation")]
CancelRequest,
#[doc(hidden)]
_Custom(String),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RequestedKeyInfo {
pub algorithm: EventEncryptionAlgorithm,
pub room_id: RoomId,
pub sender_key: String,
pub session_id: String,
}
impl RequestedKeyInfo {
pub fn new(
algorithm: EventEncryptionAlgorithm,
room_id: RoomId,
sender_key: String,
session_id: String,
) -> Self {
Self { algorithm, room_id, sender_key, session_id }
}
}