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
use js_int::{int, Int};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct NotificationPowerLevels {
#[cfg_attr(
feature = "compat",
serde(deserialize_with = "crate::serde::deserialize_v1_powerlevel")
)]
#[serde(default = "default_power_level")]
pub room: Int,
}
impl NotificationPowerLevels {
pub fn new() -> Self {
Self { room: default_power_level() }
}
pub fn get(&self, key: &str) -> Option<&Int> {
match key {
"room" => Some(&self.room),
_ => None,
}
}
}
impl Default for NotificationPowerLevels {
fn default() -> Self {
Self::new()
}
}
pub fn default_power_level() -> Int {
int!(50)
}