rust_tdlib/types/
notification_group_type.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7pub trait TDNotificationGroupType: Debug + RObject {}
9
10#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum NotificationGroupType {
14 #[doc(hidden)]
15 #[default]
16 _Default,
17 #[serde(rename = "notificationGroupTypeCalls")]
19 Calls(NotificationGroupTypeCalls),
20 #[serde(rename = "notificationGroupTypeMentions")]
22 Mentions(NotificationGroupTypeMentions),
23 #[serde(rename = "notificationGroupTypeMessages")]
25 Messages(NotificationGroupTypeMessages),
26 #[serde(rename = "notificationGroupTypeSecretChat")]
28 SecretChat(NotificationGroupTypeSecretChat),
29}
30
31impl RObject for NotificationGroupType {
32 #[doc(hidden)]
33 fn extra(&self) -> Option<&str> {
34 match self {
35 NotificationGroupType::Calls(t) => t.extra(),
36 NotificationGroupType::Mentions(t) => t.extra(),
37 NotificationGroupType::Messages(t) => t.extra(),
38 NotificationGroupType::SecretChat(t) => t.extra(),
39
40 _ => None,
41 }
42 }
43 #[doc(hidden)]
44 fn client_id(&self) -> Option<i32> {
45 match self {
46 NotificationGroupType::Calls(t) => t.client_id(),
47 NotificationGroupType::Mentions(t) => t.client_id(),
48 NotificationGroupType::Messages(t) => t.client_id(),
49 NotificationGroupType::SecretChat(t) => t.client_id(),
50
51 _ => None,
52 }
53 }
54}
55
56impl NotificationGroupType {
57 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
58 Ok(serde_json::from_str(json.as_ref())?)
59 }
60 #[doc(hidden)]
61 pub fn _is_default(&self) -> bool {
62 matches!(self, NotificationGroupType::_Default)
63 }
64}
65
66impl AsRef<NotificationGroupType> for NotificationGroupType {
67 fn as_ref(&self) -> &NotificationGroupType {
68 self
69 }
70}
71
72#[derive(Debug, Clone, Default, Serialize, Deserialize)]
74pub struct NotificationGroupTypeCalls {
75 #[doc(hidden)]
76 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
77 extra: Option<String>,
78 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
79 client_id: Option<i32>,
80}
81
82impl RObject for NotificationGroupTypeCalls {
83 #[doc(hidden)]
84 fn extra(&self) -> Option<&str> {
85 self.extra.as_deref()
86 }
87 #[doc(hidden)]
88 fn client_id(&self) -> Option<i32> {
89 self.client_id
90 }
91}
92
93impl TDNotificationGroupType for NotificationGroupTypeCalls {}
94
95impl NotificationGroupTypeCalls {
96 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
97 Ok(serde_json::from_str(json.as_ref())?)
98 }
99 pub fn builder() -> NotificationGroupTypeCallsBuilder {
100 let mut inner = NotificationGroupTypeCalls::default();
101 inner.extra = Some(Uuid::new_v4().to_string());
102
103 NotificationGroupTypeCallsBuilder { inner }
104 }
105}
106
107#[doc(hidden)]
108pub struct NotificationGroupTypeCallsBuilder {
109 inner: NotificationGroupTypeCalls,
110}
111
112#[deprecated]
113pub type RTDNotificationGroupTypeCallsBuilder = NotificationGroupTypeCallsBuilder;
114
115impl NotificationGroupTypeCallsBuilder {
116 pub fn build(&self) -> NotificationGroupTypeCalls {
117 self.inner.clone()
118 }
119}
120
121impl AsRef<NotificationGroupTypeCalls> for NotificationGroupTypeCalls {
122 fn as_ref(&self) -> &NotificationGroupTypeCalls {
123 self
124 }
125}
126
127impl AsRef<NotificationGroupTypeCalls> for NotificationGroupTypeCallsBuilder {
128 fn as_ref(&self) -> &NotificationGroupTypeCalls {
129 &self.inner
130 }
131}
132
133#[derive(Debug, Clone, Default, Serialize, Deserialize)]
135pub struct NotificationGroupTypeMentions {
136 #[doc(hidden)]
137 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
138 extra: Option<String>,
139 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
140 client_id: Option<i32>,
141}
142
143impl RObject for NotificationGroupTypeMentions {
144 #[doc(hidden)]
145 fn extra(&self) -> Option<&str> {
146 self.extra.as_deref()
147 }
148 #[doc(hidden)]
149 fn client_id(&self) -> Option<i32> {
150 self.client_id
151 }
152}
153
154impl TDNotificationGroupType for NotificationGroupTypeMentions {}
155
156impl NotificationGroupTypeMentions {
157 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
158 Ok(serde_json::from_str(json.as_ref())?)
159 }
160 pub fn builder() -> NotificationGroupTypeMentionsBuilder {
161 let mut inner = NotificationGroupTypeMentions::default();
162 inner.extra = Some(Uuid::new_v4().to_string());
163
164 NotificationGroupTypeMentionsBuilder { inner }
165 }
166}
167
168#[doc(hidden)]
169pub struct NotificationGroupTypeMentionsBuilder {
170 inner: NotificationGroupTypeMentions,
171}
172
173#[deprecated]
174pub type RTDNotificationGroupTypeMentionsBuilder = NotificationGroupTypeMentionsBuilder;
175
176impl NotificationGroupTypeMentionsBuilder {
177 pub fn build(&self) -> NotificationGroupTypeMentions {
178 self.inner.clone()
179 }
180}
181
182impl AsRef<NotificationGroupTypeMentions> for NotificationGroupTypeMentions {
183 fn as_ref(&self) -> &NotificationGroupTypeMentions {
184 self
185 }
186}
187
188impl AsRef<NotificationGroupTypeMentions> for NotificationGroupTypeMentionsBuilder {
189 fn as_ref(&self) -> &NotificationGroupTypeMentions {
190 &self.inner
191 }
192}
193
194#[derive(Debug, Clone, Default, Serialize, Deserialize)]
196pub struct NotificationGroupTypeMessages {
197 #[doc(hidden)]
198 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
199 extra: Option<String>,
200 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
201 client_id: Option<i32>,
202}
203
204impl RObject for NotificationGroupTypeMessages {
205 #[doc(hidden)]
206 fn extra(&self) -> Option<&str> {
207 self.extra.as_deref()
208 }
209 #[doc(hidden)]
210 fn client_id(&self) -> Option<i32> {
211 self.client_id
212 }
213}
214
215impl TDNotificationGroupType for NotificationGroupTypeMessages {}
216
217impl NotificationGroupTypeMessages {
218 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
219 Ok(serde_json::from_str(json.as_ref())?)
220 }
221 pub fn builder() -> NotificationGroupTypeMessagesBuilder {
222 let mut inner = NotificationGroupTypeMessages::default();
223 inner.extra = Some(Uuid::new_v4().to_string());
224
225 NotificationGroupTypeMessagesBuilder { inner }
226 }
227}
228
229#[doc(hidden)]
230pub struct NotificationGroupTypeMessagesBuilder {
231 inner: NotificationGroupTypeMessages,
232}
233
234#[deprecated]
235pub type RTDNotificationGroupTypeMessagesBuilder = NotificationGroupTypeMessagesBuilder;
236
237impl NotificationGroupTypeMessagesBuilder {
238 pub fn build(&self) -> NotificationGroupTypeMessages {
239 self.inner.clone()
240 }
241}
242
243impl AsRef<NotificationGroupTypeMessages> for NotificationGroupTypeMessages {
244 fn as_ref(&self) -> &NotificationGroupTypeMessages {
245 self
246 }
247}
248
249impl AsRef<NotificationGroupTypeMessages> for NotificationGroupTypeMessagesBuilder {
250 fn as_ref(&self) -> &NotificationGroupTypeMessages {
251 &self.inner
252 }
253}
254
255#[derive(Debug, Clone, Default, Serialize, Deserialize)]
257pub struct NotificationGroupTypeSecretChat {
258 #[doc(hidden)]
259 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
260 extra: Option<String>,
261 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
262 client_id: Option<i32>,
263}
264
265impl RObject for NotificationGroupTypeSecretChat {
266 #[doc(hidden)]
267 fn extra(&self) -> Option<&str> {
268 self.extra.as_deref()
269 }
270 #[doc(hidden)]
271 fn client_id(&self) -> Option<i32> {
272 self.client_id
273 }
274}
275
276impl TDNotificationGroupType for NotificationGroupTypeSecretChat {}
277
278impl NotificationGroupTypeSecretChat {
279 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
280 Ok(serde_json::from_str(json.as_ref())?)
281 }
282 pub fn builder() -> NotificationGroupTypeSecretChatBuilder {
283 let mut inner = NotificationGroupTypeSecretChat::default();
284 inner.extra = Some(Uuid::new_v4().to_string());
285
286 NotificationGroupTypeSecretChatBuilder { inner }
287 }
288}
289
290#[doc(hidden)]
291pub struct NotificationGroupTypeSecretChatBuilder {
292 inner: NotificationGroupTypeSecretChat,
293}
294
295#[deprecated]
296pub type RTDNotificationGroupTypeSecretChatBuilder = NotificationGroupTypeSecretChatBuilder;
297
298impl NotificationGroupTypeSecretChatBuilder {
299 pub fn build(&self) -> NotificationGroupTypeSecretChat {
300 self.inner.clone()
301 }
302}
303
304impl AsRef<NotificationGroupTypeSecretChat> for NotificationGroupTypeSecretChat {
305 fn as_ref(&self) -> &NotificationGroupTypeSecretChat {
306 self
307 }
308}
309
310impl AsRef<NotificationGroupTypeSecretChat> for NotificationGroupTypeSecretChatBuilder {
311 fn as_ref(&self) -> &NotificationGroupTypeSecretChat {
312 &self.inner
313 }
314}