1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9use std::fmt::Debug;
10use serde::de::{Deserialize, Deserializer};
11
12
13
14pub trait TDUserPrivacySettingRule: Debug + RObject {}
16
17#[derive(Debug, Clone, Serialize)]
19#[serde(untagged)]
20pub enum UserPrivacySettingRule {
21 #[doc(hidden)] _Default(()),
22 AllowAll(UserPrivacySettingRuleAllowAll),
24 AllowChatMembers(UserPrivacySettingRuleAllowChatMembers),
26 AllowContacts(UserPrivacySettingRuleAllowContacts),
28 AllowUsers(UserPrivacySettingRuleAllowUsers),
30 RestrictAll(UserPrivacySettingRuleRestrictAll),
32 RestrictChatMembers(UserPrivacySettingRuleRestrictChatMembers),
34 RestrictContacts(UserPrivacySettingRuleRestrictContacts),
36 RestrictUsers(UserPrivacySettingRuleRestrictUsers),
38
39}
40
41impl Default for UserPrivacySettingRule {
42 fn default() -> Self { UserPrivacySettingRule::_Default(()) }
43}
44
45impl<'de> Deserialize<'de> for UserPrivacySettingRule {
46 fn deserialize<D>(deserializer: D) -> Result<UserPrivacySettingRule, D::Error> where D: Deserializer<'de> {
47 use serde::de::Error;
48 rtd_enum_deserialize!(
49 UserPrivacySettingRule,
50 (userPrivacySettingRuleAllowAll, AllowAll);
51 (userPrivacySettingRuleAllowChatMembers, AllowChatMembers);
52 (userPrivacySettingRuleAllowContacts, AllowContacts);
53 (userPrivacySettingRuleAllowUsers, AllowUsers);
54 (userPrivacySettingRuleRestrictAll, RestrictAll);
55 (userPrivacySettingRuleRestrictChatMembers, RestrictChatMembers);
56 (userPrivacySettingRuleRestrictContacts, RestrictContacts);
57 (userPrivacySettingRuleRestrictUsers, RestrictUsers);
58
59 )(deserializer)
60 }
61}
62
63impl RObject for UserPrivacySettingRule {
64 #[doc(hidden)] fn td_name(&self) -> &'static str {
65 match self {
66 UserPrivacySettingRule::AllowAll(t) => t.td_name(),
67 UserPrivacySettingRule::AllowChatMembers(t) => t.td_name(),
68 UserPrivacySettingRule::AllowContacts(t) => t.td_name(),
69 UserPrivacySettingRule::AllowUsers(t) => t.td_name(),
70 UserPrivacySettingRule::RestrictAll(t) => t.td_name(),
71 UserPrivacySettingRule::RestrictChatMembers(t) => t.td_name(),
72 UserPrivacySettingRule::RestrictContacts(t) => t.td_name(),
73 UserPrivacySettingRule::RestrictUsers(t) => t.td_name(),
74
75 _ => "-1",
76 }
77 }
78 #[doc(hidden)] fn extra(&self) -> Option<String> {
79 match self {
80 UserPrivacySettingRule::AllowAll(t) => t.extra(),
81 UserPrivacySettingRule::AllowChatMembers(t) => t.extra(),
82 UserPrivacySettingRule::AllowContacts(t) => t.extra(),
83 UserPrivacySettingRule::AllowUsers(t) => t.extra(),
84 UserPrivacySettingRule::RestrictAll(t) => t.extra(),
85 UserPrivacySettingRule::RestrictChatMembers(t) => t.extra(),
86 UserPrivacySettingRule::RestrictContacts(t) => t.extra(),
87 UserPrivacySettingRule::RestrictUsers(t) => t.extra(),
88
89 _ => None,
90 }
91 }
92 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
93}
94
95impl UserPrivacySettingRule {
96 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
97 #[doc(hidden)] pub fn _is_default(&self) -> bool { if let UserPrivacySettingRule::_Default(_) = self { true } else { false } }
98
99 pub fn is_allow_all(&self) -> bool { if let UserPrivacySettingRule::AllowAll(_) = self { true } else { false } }
100 pub fn is_allow_chat_members(&self) -> bool { if let UserPrivacySettingRule::AllowChatMembers(_) = self { true } else { false } }
101 pub fn is_allow_contacts(&self) -> bool { if let UserPrivacySettingRule::AllowContacts(_) = self { true } else { false } }
102 pub fn is_allow_users(&self) -> bool { if let UserPrivacySettingRule::AllowUsers(_) = self { true } else { false } }
103 pub fn is_restrict_all(&self) -> bool { if let UserPrivacySettingRule::RestrictAll(_) = self { true } else { false } }
104 pub fn is_restrict_chat_members(&self) -> bool { if let UserPrivacySettingRule::RestrictChatMembers(_) = self { true } else { false } }
105 pub fn is_restrict_contacts(&self) -> bool { if let UserPrivacySettingRule::RestrictContacts(_) = self { true } else { false } }
106 pub fn is_restrict_users(&self) -> bool { if let UserPrivacySettingRule::RestrictUsers(_) = self { true } else { false } }
107
108 pub fn on_allow_all<F: FnOnce(&UserPrivacySettingRuleAllowAll)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::AllowAll(t) = self { fnc(t) }; self }
109 pub fn on_allow_chat_members<F: FnOnce(&UserPrivacySettingRuleAllowChatMembers)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::AllowChatMembers(t) = self { fnc(t) }; self }
110 pub fn on_allow_contacts<F: FnOnce(&UserPrivacySettingRuleAllowContacts)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::AllowContacts(t) = self { fnc(t) }; self }
111 pub fn on_allow_users<F: FnOnce(&UserPrivacySettingRuleAllowUsers)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::AllowUsers(t) = self { fnc(t) }; self }
112 pub fn on_restrict_all<F: FnOnce(&UserPrivacySettingRuleRestrictAll)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::RestrictAll(t) = self { fnc(t) }; self }
113 pub fn on_restrict_chat_members<F: FnOnce(&UserPrivacySettingRuleRestrictChatMembers)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::RestrictChatMembers(t) = self { fnc(t) }; self }
114 pub fn on_restrict_contacts<F: FnOnce(&UserPrivacySettingRuleRestrictContacts)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::RestrictContacts(t) = self { fnc(t) }; self }
115 pub fn on_restrict_users<F: FnOnce(&UserPrivacySettingRuleRestrictUsers)>(&self, fnc: F) -> &Self { if let UserPrivacySettingRule::RestrictUsers(t) = self { fnc(t) }; self }
116
117 pub fn as_allow_all(&self) -> Option<&UserPrivacySettingRuleAllowAll> { if let UserPrivacySettingRule::AllowAll(t) = self { return Some(t) } None }
118 pub fn as_allow_chat_members(&self) -> Option<&UserPrivacySettingRuleAllowChatMembers> { if let UserPrivacySettingRule::AllowChatMembers(t) = self { return Some(t) } None }
119 pub fn as_allow_contacts(&self) -> Option<&UserPrivacySettingRuleAllowContacts> { if let UserPrivacySettingRule::AllowContacts(t) = self { return Some(t) } None }
120 pub fn as_allow_users(&self) -> Option<&UserPrivacySettingRuleAllowUsers> { if let UserPrivacySettingRule::AllowUsers(t) = self { return Some(t) } None }
121 pub fn as_restrict_all(&self) -> Option<&UserPrivacySettingRuleRestrictAll> { if let UserPrivacySettingRule::RestrictAll(t) = self { return Some(t) } None }
122 pub fn as_restrict_chat_members(&self) -> Option<&UserPrivacySettingRuleRestrictChatMembers> { if let UserPrivacySettingRule::RestrictChatMembers(t) = self { return Some(t) } None }
123 pub fn as_restrict_contacts(&self) -> Option<&UserPrivacySettingRuleRestrictContacts> { if let UserPrivacySettingRule::RestrictContacts(t) = self { return Some(t) } None }
124 pub fn as_restrict_users(&self) -> Option<&UserPrivacySettingRuleRestrictUsers> { if let UserPrivacySettingRule::RestrictUsers(t) = self { return Some(t) } None }
125
126
127
128 pub fn allow_all<T: AsRef<UserPrivacySettingRuleAllowAll>>(t: T) -> Self { UserPrivacySettingRule::AllowAll(t.as_ref().clone()) }
129
130 pub fn allow_chat_members<T: AsRef<UserPrivacySettingRuleAllowChatMembers>>(t: T) -> Self { UserPrivacySettingRule::AllowChatMembers(t.as_ref().clone()) }
131
132 pub fn allow_contacts<T: AsRef<UserPrivacySettingRuleAllowContacts>>(t: T) -> Self { UserPrivacySettingRule::AllowContacts(t.as_ref().clone()) }
133
134 pub fn allow_users<T: AsRef<UserPrivacySettingRuleAllowUsers>>(t: T) -> Self { UserPrivacySettingRule::AllowUsers(t.as_ref().clone()) }
135
136 pub fn restrict_all<T: AsRef<UserPrivacySettingRuleRestrictAll>>(t: T) -> Self { UserPrivacySettingRule::RestrictAll(t.as_ref().clone()) }
137
138 pub fn restrict_chat_members<T: AsRef<UserPrivacySettingRuleRestrictChatMembers>>(t: T) -> Self { UserPrivacySettingRule::RestrictChatMembers(t.as_ref().clone()) }
139
140 pub fn restrict_contacts<T: AsRef<UserPrivacySettingRuleRestrictContacts>>(t: T) -> Self { UserPrivacySettingRule::RestrictContacts(t.as_ref().clone()) }
141
142 pub fn restrict_users<T: AsRef<UserPrivacySettingRuleRestrictUsers>>(t: T) -> Self { UserPrivacySettingRule::RestrictUsers(t.as_ref().clone()) }
143
144}
145
146impl AsRef<UserPrivacySettingRule> for UserPrivacySettingRule {
147 fn as_ref(&self) -> &UserPrivacySettingRule { self }
148}
149
150
151
152
153
154
155
156#[derive(Debug, Clone, Default, Serialize, Deserialize)]
158pub struct UserPrivacySettingRuleAllowAll {
159 #[doc(hidden)]
160 #[serde(rename(serialize = "@type", deserialize = "@type"))]
161 td_name: String,
162 #[doc(hidden)]
163 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
164 extra: Option<String>,
165
166}
167
168impl RObject for UserPrivacySettingRuleAllowAll {
169 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleAllowAll" }
170 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
171 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
172}
173
174
175impl TDUserPrivacySettingRule for UserPrivacySettingRuleAllowAll {}
176
177
178
179impl UserPrivacySettingRuleAllowAll {
180 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
181 pub fn builder() -> RTDUserPrivacySettingRuleAllowAllBuilder {
182 let mut inner = UserPrivacySettingRuleAllowAll::default();
183 inner.td_name = "userPrivacySettingRuleAllowAll".to_string();
184 inner.extra = Some(Uuid::new_v4().to_string());
185 RTDUserPrivacySettingRuleAllowAllBuilder { inner }
186 }
187
188}
189
190#[doc(hidden)]
191pub struct RTDUserPrivacySettingRuleAllowAllBuilder {
192 inner: UserPrivacySettingRuleAllowAll
193}
194
195impl RTDUserPrivacySettingRuleAllowAllBuilder {
196 pub fn build(&self) -> UserPrivacySettingRuleAllowAll { self.inner.clone() }
197
198}
199
200impl AsRef<UserPrivacySettingRuleAllowAll> for UserPrivacySettingRuleAllowAll {
201 fn as_ref(&self) -> &UserPrivacySettingRuleAllowAll { self }
202}
203
204impl AsRef<UserPrivacySettingRuleAllowAll> for RTDUserPrivacySettingRuleAllowAllBuilder {
205 fn as_ref(&self) -> &UserPrivacySettingRuleAllowAll { &self.inner }
206}
207
208
209
210
211
212
213
214#[derive(Debug, Clone, Default, Serialize, Deserialize)]
216pub struct UserPrivacySettingRuleAllowChatMembers {
217 #[doc(hidden)]
218 #[serde(rename(serialize = "@type", deserialize = "@type"))]
219 td_name: String,
220 #[doc(hidden)]
221 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
222 extra: Option<String>,
223 chat_ids: Vec<i64>,
225
226}
227
228impl RObject for UserPrivacySettingRuleAllowChatMembers {
229 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleAllowChatMembers" }
230 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
231 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
232}
233
234
235impl TDUserPrivacySettingRule for UserPrivacySettingRuleAllowChatMembers {}
236
237
238
239impl UserPrivacySettingRuleAllowChatMembers {
240 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
241 pub fn builder() -> RTDUserPrivacySettingRuleAllowChatMembersBuilder {
242 let mut inner = UserPrivacySettingRuleAllowChatMembers::default();
243 inner.td_name = "userPrivacySettingRuleAllowChatMembers".to_string();
244 inner.extra = Some(Uuid::new_v4().to_string());
245 RTDUserPrivacySettingRuleAllowChatMembersBuilder { inner }
246 }
247
248 pub fn chat_ids(&self) -> &Vec<i64> { &self.chat_ids }
249
250}
251
252#[doc(hidden)]
253pub struct RTDUserPrivacySettingRuleAllowChatMembersBuilder {
254 inner: UserPrivacySettingRuleAllowChatMembers
255}
256
257impl RTDUserPrivacySettingRuleAllowChatMembersBuilder {
258 pub fn build(&self) -> UserPrivacySettingRuleAllowChatMembers { self.inner.clone() }
259
260
261 pub fn chat_ids(&mut self, chat_ids: Vec<i64>) -> &mut Self {
262 self.inner.chat_ids = chat_ids;
263 self
264 }
265
266}
267
268impl AsRef<UserPrivacySettingRuleAllowChatMembers> for UserPrivacySettingRuleAllowChatMembers {
269 fn as_ref(&self) -> &UserPrivacySettingRuleAllowChatMembers { self }
270}
271
272impl AsRef<UserPrivacySettingRuleAllowChatMembers> for RTDUserPrivacySettingRuleAllowChatMembersBuilder {
273 fn as_ref(&self) -> &UserPrivacySettingRuleAllowChatMembers { &self.inner }
274}
275
276
277
278
279
280
281
282#[derive(Debug, Clone, Default, Serialize, Deserialize)]
284pub struct UserPrivacySettingRuleAllowContacts {
285 #[doc(hidden)]
286 #[serde(rename(serialize = "@type", deserialize = "@type"))]
287 td_name: String,
288 #[doc(hidden)]
289 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
290 extra: Option<String>,
291
292}
293
294impl RObject for UserPrivacySettingRuleAllowContacts {
295 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleAllowContacts" }
296 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
297 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
298}
299
300
301impl TDUserPrivacySettingRule for UserPrivacySettingRuleAllowContacts {}
302
303
304
305impl UserPrivacySettingRuleAllowContacts {
306 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
307 pub fn builder() -> RTDUserPrivacySettingRuleAllowContactsBuilder {
308 let mut inner = UserPrivacySettingRuleAllowContacts::default();
309 inner.td_name = "userPrivacySettingRuleAllowContacts".to_string();
310 inner.extra = Some(Uuid::new_v4().to_string());
311 RTDUserPrivacySettingRuleAllowContactsBuilder { inner }
312 }
313
314}
315
316#[doc(hidden)]
317pub struct RTDUserPrivacySettingRuleAllowContactsBuilder {
318 inner: UserPrivacySettingRuleAllowContacts
319}
320
321impl RTDUserPrivacySettingRuleAllowContactsBuilder {
322 pub fn build(&self) -> UserPrivacySettingRuleAllowContacts { self.inner.clone() }
323
324}
325
326impl AsRef<UserPrivacySettingRuleAllowContacts> for UserPrivacySettingRuleAllowContacts {
327 fn as_ref(&self) -> &UserPrivacySettingRuleAllowContacts { self }
328}
329
330impl AsRef<UserPrivacySettingRuleAllowContacts> for RTDUserPrivacySettingRuleAllowContactsBuilder {
331 fn as_ref(&self) -> &UserPrivacySettingRuleAllowContacts { &self.inner }
332}
333
334
335
336
337
338
339
340#[derive(Debug, Clone, Default, Serialize, Deserialize)]
342pub struct UserPrivacySettingRuleAllowUsers {
343 #[doc(hidden)]
344 #[serde(rename(serialize = "@type", deserialize = "@type"))]
345 td_name: String,
346 #[doc(hidden)]
347 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
348 extra: Option<String>,
349 user_ids: Vec<i64>,
351
352}
353
354impl RObject for UserPrivacySettingRuleAllowUsers {
355 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleAllowUsers" }
356 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
357 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
358}
359
360
361impl TDUserPrivacySettingRule for UserPrivacySettingRuleAllowUsers {}
362
363
364
365impl UserPrivacySettingRuleAllowUsers {
366 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
367 pub fn builder() -> RTDUserPrivacySettingRuleAllowUsersBuilder {
368 let mut inner = UserPrivacySettingRuleAllowUsers::default();
369 inner.td_name = "userPrivacySettingRuleAllowUsers".to_string();
370 inner.extra = Some(Uuid::new_v4().to_string());
371 RTDUserPrivacySettingRuleAllowUsersBuilder { inner }
372 }
373
374 pub fn user_ids(&self) -> &Vec<i64> { &self.user_ids }
375
376}
377
378#[doc(hidden)]
379pub struct RTDUserPrivacySettingRuleAllowUsersBuilder {
380 inner: UserPrivacySettingRuleAllowUsers
381}
382
383impl RTDUserPrivacySettingRuleAllowUsersBuilder {
384 pub fn build(&self) -> UserPrivacySettingRuleAllowUsers { self.inner.clone() }
385
386
387 pub fn user_ids(&mut self, user_ids: Vec<i64>) -> &mut Self {
388 self.inner.user_ids = user_ids;
389 self
390 }
391
392}
393
394impl AsRef<UserPrivacySettingRuleAllowUsers> for UserPrivacySettingRuleAllowUsers {
395 fn as_ref(&self) -> &UserPrivacySettingRuleAllowUsers { self }
396}
397
398impl AsRef<UserPrivacySettingRuleAllowUsers> for RTDUserPrivacySettingRuleAllowUsersBuilder {
399 fn as_ref(&self) -> &UserPrivacySettingRuleAllowUsers { &self.inner }
400}
401
402
403
404
405
406
407
408#[derive(Debug, Clone, Default, Serialize, Deserialize)]
410pub struct UserPrivacySettingRuleRestrictAll {
411 #[doc(hidden)]
412 #[serde(rename(serialize = "@type", deserialize = "@type"))]
413 td_name: String,
414 #[doc(hidden)]
415 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
416 extra: Option<String>,
417
418}
419
420impl RObject for UserPrivacySettingRuleRestrictAll {
421 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleRestrictAll" }
422 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
423 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
424}
425
426
427impl TDUserPrivacySettingRule for UserPrivacySettingRuleRestrictAll {}
428
429
430
431impl UserPrivacySettingRuleRestrictAll {
432 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
433 pub fn builder() -> RTDUserPrivacySettingRuleRestrictAllBuilder {
434 let mut inner = UserPrivacySettingRuleRestrictAll::default();
435 inner.td_name = "userPrivacySettingRuleRestrictAll".to_string();
436 inner.extra = Some(Uuid::new_v4().to_string());
437 RTDUserPrivacySettingRuleRestrictAllBuilder { inner }
438 }
439
440}
441
442#[doc(hidden)]
443pub struct RTDUserPrivacySettingRuleRestrictAllBuilder {
444 inner: UserPrivacySettingRuleRestrictAll
445}
446
447impl RTDUserPrivacySettingRuleRestrictAllBuilder {
448 pub fn build(&self) -> UserPrivacySettingRuleRestrictAll { self.inner.clone() }
449
450}
451
452impl AsRef<UserPrivacySettingRuleRestrictAll> for UserPrivacySettingRuleRestrictAll {
453 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictAll { self }
454}
455
456impl AsRef<UserPrivacySettingRuleRestrictAll> for RTDUserPrivacySettingRuleRestrictAllBuilder {
457 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictAll { &self.inner }
458}
459
460
461
462
463
464
465
466#[derive(Debug, Clone, Default, Serialize, Deserialize)]
468pub struct UserPrivacySettingRuleRestrictChatMembers {
469 #[doc(hidden)]
470 #[serde(rename(serialize = "@type", deserialize = "@type"))]
471 td_name: String,
472 #[doc(hidden)]
473 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
474 extra: Option<String>,
475 chat_ids: Vec<i64>,
477
478}
479
480impl RObject for UserPrivacySettingRuleRestrictChatMembers {
481 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleRestrictChatMembers" }
482 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
483 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
484}
485
486
487impl TDUserPrivacySettingRule for UserPrivacySettingRuleRestrictChatMembers {}
488
489
490
491impl UserPrivacySettingRuleRestrictChatMembers {
492 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
493 pub fn builder() -> RTDUserPrivacySettingRuleRestrictChatMembersBuilder {
494 let mut inner = UserPrivacySettingRuleRestrictChatMembers::default();
495 inner.td_name = "userPrivacySettingRuleRestrictChatMembers".to_string();
496 inner.extra = Some(Uuid::new_v4().to_string());
497 RTDUserPrivacySettingRuleRestrictChatMembersBuilder { inner }
498 }
499
500 pub fn chat_ids(&self) -> &Vec<i64> { &self.chat_ids }
501
502}
503
504#[doc(hidden)]
505pub struct RTDUserPrivacySettingRuleRestrictChatMembersBuilder {
506 inner: UserPrivacySettingRuleRestrictChatMembers
507}
508
509impl RTDUserPrivacySettingRuleRestrictChatMembersBuilder {
510 pub fn build(&self) -> UserPrivacySettingRuleRestrictChatMembers { self.inner.clone() }
511
512
513 pub fn chat_ids(&mut self, chat_ids: Vec<i64>) -> &mut Self {
514 self.inner.chat_ids = chat_ids;
515 self
516 }
517
518}
519
520impl AsRef<UserPrivacySettingRuleRestrictChatMembers> for UserPrivacySettingRuleRestrictChatMembers {
521 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictChatMembers { self }
522}
523
524impl AsRef<UserPrivacySettingRuleRestrictChatMembers> for RTDUserPrivacySettingRuleRestrictChatMembersBuilder {
525 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictChatMembers { &self.inner }
526}
527
528
529
530
531
532
533
534#[derive(Debug, Clone, Default, Serialize, Deserialize)]
536pub struct UserPrivacySettingRuleRestrictContacts {
537 #[doc(hidden)]
538 #[serde(rename(serialize = "@type", deserialize = "@type"))]
539 td_name: String,
540 #[doc(hidden)]
541 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
542 extra: Option<String>,
543
544}
545
546impl RObject for UserPrivacySettingRuleRestrictContacts {
547 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleRestrictContacts" }
548 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
549 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
550}
551
552
553impl TDUserPrivacySettingRule for UserPrivacySettingRuleRestrictContacts {}
554
555
556
557impl UserPrivacySettingRuleRestrictContacts {
558 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
559 pub fn builder() -> RTDUserPrivacySettingRuleRestrictContactsBuilder {
560 let mut inner = UserPrivacySettingRuleRestrictContacts::default();
561 inner.td_name = "userPrivacySettingRuleRestrictContacts".to_string();
562 inner.extra = Some(Uuid::new_v4().to_string());
563 RTDUserPrivacySettingRuleRestrictContactsBuilder { inner }
564 }
565
566}
567
568#[doc(hidden)]
569pub struct RTDUserPrivacySettingRuleRestrictContactsBuilder {
570 inner: UserPrivacySettingRuleRestrictContacts
571}
572
573impl RTDUserPrivacySettingRuleRestrictContactsBuilder {
574 pub fn build(&self) -> UserPrivacySettingRuleRestrictContacts { self.inner.clone() }
575
576}
577
578impl AsRef<UserPrivacySettingRuleRestrictContacts> for UserPrivacySettingRuleRestrictContacts {
579 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictContacts { self }
580}
581
582impl AsRef<UserPrivacySettingRuleRestrictContacts> for RTDUserPrivacySettingRuleRestrictContactsBuilder {
583 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictContacts { &self.inner }
584}
585
586
587
588
589
590
591
592#[derive(Debug, Clone, Default, Serialize, Deserialize)]
594pub struct UserPrivacySettingRuleRestrictUsers {
595 #[doc(hidden)]
596 #[serde(rename(serialize = "@type", deserialize = "@type"))]
597 td_name: String,
598 #[doc(hidden)]
599 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
600 extra: Option<String>,
601 user_ids: Vec<i64>,
603
604}
605
606impl RObject for UserPrivacySettingRuleRestrictUsers {
607 #[doc(hidden)] fn td_name(&self) -> &'static str { "userPrivacySettingRuleRestrictUsers" }
608 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
609 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
610}
611
612
613impl TDUserPrivacySettingRule for UserPrivacySettingRuleRestrictUsers {}
614
615
616
617impl UserPrivacySettingRuleRestrictUsers {
618 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
619 pub fn builder() -> RTDUserPrivacySettingRuleRestrictUsersBuilder {
620 let mut inner = UserPrivacySettingRuleRestrictUsers::default();
621 inner.td_name = "userPrivacySettingRuleRestrictUsers".to_string();
622 inner.extra = Some(Uuid::new_v4().to_string());
623 RTDUserPrivacySettingRuleRestrictUsersBuilder { inner }
624 }
625
626 pub fn user_ids(&self) -> &Vec<i64> { &self.user_ids }
627
628}
629
630#[doc(hidden)]
631pub struct RTDUserPrivacySettingRuleRestrictUsersBuilder {
632 inner: UserPrivacySettingRuleRestrictUsers
633}
634
635impl RTDUserPrivacySettingRuleRestrictUsersBuilder {
636 pub fn build(&self) -> UserPrivacySettingRuleRestrictUsers { self.inner.clone() }
637
638
639 pub fn user_ids(&mut self, user_ids: Vec<i64>) -> &mut Self {
640 self.inner.user_ids = user_ids;
641 self
642 }
643
644}
645
646impl AsRef<UserPrivacySettingRuleRestrictUsers> for UserPrivacySettingRuleRestrictUsers {
647 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictUsers { self }
648}
649
650impl AsRef<UserPrivacySettingRuleRestrictUsers> for RTDUserPrivacySettingRuleRestrictUsersBuilder {
651 fn as_ref(&self) -> &UserPrivacySettingRuleRestrictUsers { &self.inner }
652}
653
654
655