rtdlib/types/
scope_notification_settings.rs1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct ScopeNotificationSettings {
12 #[doc(hidden)]
13 #[serde(rename(serialize = "@type", deserialize = "@type"))]
14 td_name: String,
15 #[doc(hidden)]
16 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17 extra: Option<String>,
18 mute_for: i64,
20 sound: String,
22 show_preview: bool,
24 disable_pinned_message_notifications: bool,
26 disable_mention_notifications: bool,
28
29}
30
31impl RObject for ScopeNotificationSettings {
32 #[doc(hidden)] fn td_name(&self) -> &'static str { "scopeNotificationSettings" }
33 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
34 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
35}
36
37
38
39impl ScopeNotificationSettings {
40 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
41 pub fn builder() -> RTDScopeNotificationSettingsBuilder {
42 let mut inner = ScopeNotificationSettings::default();
43 inner.td_name = "scopeNotificationSettings".to_string();
44 inner.extra = Some(Uuid::new_v4().to_string());
45 RTDScopeNotificationSettingsBuilder { inner }
46 }
47
48 pub fn mute_for(&self) -> i64 { self.mute_for }
49
50 pub fn sound(&self) -> &String { &self.sound }
51
52 pub fn show_preview(&self) -> bool { self.show_preview }
53
54 pub fn disable_pinned_message_notifications(&self) -> bool { self.disable_pinned_message_notifications }
55
56 pub fn disable_mention_notifications(&self) -> bool { self.disable_mention_notifications }
57
58}
59
60#[doc(hidden)]
61pub struct RTDScopeNotificationSettingsBuilder {
62 inner: ScopeNotificationSettings
63}
64
65impl RTDScopeNotificationSettingsBuilder {
66 pub fn build(&self) -> ScopeNotificationSettings { self.inner.clone() }
67
68
69 pub fn mute_for(&mut self, mute_for: i64) -> &mut Self {
70 self.inner.mute_for = mute_for;
71 self
72 }
73
74
75 pub fn sound<T: AsRef<str>>(&mut self, sound: T) -> &mut Self {
76 self.inner.sound = sound.as_ref().to_string();
77 self
78 }
79
80
81 pub fn show_preview(&mut self, show_preview: bool) -> &mut Self {
82 self.inner.show_preview = show_preview;
83 self
84 }
85
86
87 pub fn disable_pinned_message_notifications(&mut self, disable_pinned_message_notifications: bool) -> &mut Self {
88 self.inner.disable_pinned_message_notifications = disable_pinned_message_notifications;
89 self
90 }
91
92
93 pub fn disable_mention_notifications(&mut self, disable_mention_notifications: bool) -> &mut Self {
94 self.inner.disable_mention_notifications = disable_mention_notifications;
95 self
96 }
97
98}
99
100impl AsRef<ScopeNotificationSettings> for ScopeNotificationSettings {
101 fn as_ref(&self) -> &ScopeNotificationSettings { self }
102}
103
104impl AsRef<ScopeNotificationSettings> for RTDScopeNotificationSettingsBuilder {
105 fn as_ref(&self) -> &ScopeNotificationSettings { &self.inner }
106}
107
108
109