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
93
94
95
96
97
98
99
100
use serde::{Deserialize, Serialize};
#[derive(
Debug, PartialEq, Eq, Clone, Copy, Hash, Serialize, Deserialize, Default,
)]
#[non_exhaustive]
#[must_use]
pub struct Permissions {
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_media_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_polls: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_other_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_web_page_previews: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_info: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_invite_users: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>,
}
impl Permissions {
pub fn new() -> Self {
Self::default()
}
pub const fn can_send_messages(mut self, can_send: bool) -> Self {
self.can_send_messages = Some(can_send);
self
}
pub const fn can_send_media_messages(mut self, can_send: bool) -> Self {
self.can_send_media_messages = Some(can_send);
self
}
pub const fn can_send_polls(mut self, can_send: bool) -> Self {
self.can_send_polls = Some(can_send);
self
}
pub const fn can_send_other_messages(mut self, can_send: bool) -> Self {
self.can_send_other_messages = Some(can_send);
self
}
pub const fn can_add_web_page_previews(mut self, can_add: bool) -> Self {
self.can_add_web_page_previews = Some(can_add);
self
}
pub const fn can_change_info(mut self, can_change: bool) -> Self {
self.can_change_info = Some(can_change);
self
}
pub const fn can_invite_users(mut self, can_invite: bool) -> Self {
self.can_change_info = Some(can_invite);
self
}
pub const fn can_pin_messages(mut self, can_pin: bool) -> Self {
self.can_change_info = Some(can_pin);
self
}
}