rtdlib 1.8.69

TDLib for rust
Documentation
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;

use serde::de::{Deserialize, Deserializer};
use std::fmt::Debug;

/// TRAIT | Describes a tab shown in a user or a chat profile
pub trait TDProfileTab: Debug + RObject {}

/// Describes a tab shown in a user or a chat profile
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum ProfileTab {
  #[doc(hidden)]
  _Default(()),
  /// A tab with documents posted by the channel
  Files(ProfileTabFiles),
  /// A tab with animations posted by the channel
  Gifs(ProfileTabGifs),
  /// A tab with gifts received by the user or the channel chat
  Gifts(ProfileTabGifts),
  /// A tab with messages posted by the channel and containing links
  Links(ProfileTabLinks),
  /// A tab with photos and videos posted by the channel
  Media(ProfileTabMedia),
  /// A tab with audio messages posted by the channel
  Music(ProfileTabMusic),
  /// A tab with stories posted by the user or the channel chat and saved to profile
  Posts(ProfileTabPosts),
  /// A tab with voice notes posted by the channel
  Voice(ProfileTabVoice),
}

impl Default for ProfileTab {
  fn default() -> Self {
    ProfileTab::_Default(())
  }
}

impl<'de> Deserialize<'de> for ProfileTab {
  fn deserialize<D>(deserializer: D) -> Result<ProfileTab, D::Error>
  where
    D: Deserializer<'de>,
  {
    use serde::de::Error;
    rtd_enum_deserialize!(
      ProfileTab,
      (profileTabFiles, Files);
      (profileTabGifs, Gifs);
      (profileTabGifts, Gifts);
      (profileTabLinks, Links);
      (profileTabMedia, Media);
      (profileTabMusic, Music);
      (profileTabPosts, Posts);
      (profileTabVoice, Voice);

    )(deserializer)
  }
}

impl RObject for ProfileTab {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    match self {
      ProfileTab::Files(t) => t.td_name(),
      ProfileTab::Gifs(t) => t.td_name(),
      ProfileTab::Gifts(t) => t.td_name(),
      ProfileTab::Links(t) => t.td_name(),
      ProfileTab::Media(t) => t.td_name(),
      ProfileTab::Music(t) => t.td_name(),
      ProfileTab::Posts(t) => t.td_name(),
      ProfileTab::Voice(t) => t.td_name(),

      _ => "-1",
    }
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    match self {
      ProfileTab::Files(t) => t.extra(),
      ProfileTab::Gifs(t) => t.extra(),
      ProfileTab::Gifts(t) => t.extra(),
      ProfileTab::Links(t) => t.extra(),
      ProfileTab::Media(t) => t.extra(),
      ProfileTab::Music(t) => t.extra(),
      ProfileTab::Posts(t) => t.extra(),
      ProfileTab::Voice(t) => t.extra(),

      _ => None,
    }
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl ProfileTab {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  #[doc(hidden)]
  pub fn _is_default(&self) -> bool {
    matches!(self, ProfileTab::_Default(_))
  }

  pub fn is_files(&self) -> bool {
    matches!(self, ProfileTab::Files(_))
  }
  pub fn is_gifs(&self) -> bool {
    matches!(self, ProfileTab::Gifs(_))
  }
  pub fn is_gifts(&self) -> bool {
    matches!(self, ProfileTab::Gifts(_))
  }
  pub fn is_links(&self) -> bool {
    matches!(self, ProfileTab::Links(_))
  }
  pub fn is_media(&self) -> bool {
    matches!(self, ProfileTab::Media(_))
  }
  pub fn is_music(&self) -> bool {
    matches!(self, ProfileTab::Music(_))
  }
  pub fn is_posts(&self) -> bool {
    matches!(self, ProfileTab::Posts(_))
  }
  pub fn is_voice(&self) -> bool {
    matches!(self, ProfileTab::Voice(_))
  }

  pub fn on_files<F: FnOnce(&ProfileTabFiles)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Files(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_gifs<F: FnOnce(&ProfileTabGifs)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Gifs(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_gifts<F: FnOnce(&ProfileTabGifts)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Gifts(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_links<F: FnOnce(&ProfileTabLinks)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Links(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_media<F: FnOnce(&ProfileTabMedia)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Media(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_music<F: FnOnce(&ProfileTabMusic)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Music(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_posts<F: FnOnce(&ProfileTabPosts)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Posts(t) = self {
      fnc(t)
    };
    self
  }
  pub fn on_voice<F: FnOnce(&ProfileTabVoice)>(&self, fnc: F) -> &Self {
    if let ProfileTab::Voice(t) = self {
      fnc(t)
    };
    self
  }

  pub fn as_files(&self) -> Option<&ProfileTabFiles> {
    if let ProfileTab::Files(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_gifs(&self) -> Option<&ProfileTabGifs> {
    if let ProfileTab::Gifs(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_gifts(&self) -> Option<&ProfileTabGifts> {
    if let ProfileTab::Gifts(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_links(&self) -> Option<&ProfileTabLinks> {
    if let ProfileTab::Links(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_media(&self) -> Option<&ProfileTabMedia> {
    if let ProfileTab::Media(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_music(&self) -> Option<&ProfileTabMusic> {
    if let ProfileTab::Music(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_posts(&self) -> Option<&ProfileTabPosts> {
    if let ProfileTab::Posts(t) = self {
      return Some(t);
    }
    None
  }
  pub fn as_voice(&self) -> Option<&ProfileTabVoice> {
    if let ProfileTab::Voice(t) = self {
      return Some(t);
    }
    None
  }

  pub fn files<T: AsRef<ProfileTabFiles>>(t: T) -> Self {
    ProfileTab::Files(t.as_ref().clone())
  }

  pub fn gifs<T: AsRef<ProfileTabGifs>>(t: T) -> Self {
    ProfileTab::Gifs(t.as_ref().clone())
  }

  pub fn gifts<T: AsRef<ProfileTabGifts>>(t: T) -> Self {
    ProfileTab::Gifts(t.as_ref().clone())
  }

  pub fn links<T: AsRef<ProfileTabLinks>>(t: T) -> Self {
    ProfileTab::Links(t.as_ref().clone())
  }

  pub fn media<T: AsRef<ProfileTabMedia>>(t: T) -> Self {
    ProfileTab::Media(t.as_ref().clone())
  }

  pub fn music<T: AsRef<ProfileTabMusic>>(t: T) -> Self {
    ProfileTab::Music(t.as_ref().clone())
  }

  pub fn posts<T: AsRef<ProfileTabPosts>>(t: T) -> Self {
    ProfileTab::Posts(t.as_ref().clone())
  }

  pub fn voice<T: AsRef<ProfileTabVoice>>(t: T) -> Self {
    ProfileTab::Voice(t.as_ref().clone())
  }
}

impl AsRef<ProfileTab> for ProfileTab {
  fn as_ref(&self) -> &ProfileTab {
    self
  }
}

/// A tab with documents posted by the channel
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabFiles {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabFiles {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabFiles"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabFiles {}

impl ProfileTabFiles {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabFilesBuilder {
    let inner = ProfileTabFiles {
      td_name: "profileTabFiles".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabFilesBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabFilesBuilder {
  inner: ProfileTabFiles,
}

impl RTDProfileTabFilesBuilder {
  pub fn build(&self) -> ProfileTabFiles {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabFiles> for ProfileTabFiles {
  fn as_ref(&self) -> &ProfileTabFiles {
    self
  }
}

impl AsRef<ProfileTabFiles> for RTDProfileTabFilesBuilder {
  fn as_ref(&self) -> &ProfileTabFiles {
    &self.inner
  }
}

/// A tab with animations posted by the channel
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabGifs {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabGifs {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabGifs"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabGifs {}

impl ProfileTabGifs {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabGifsBuilder {
    let inner = ProfileTabGifs {
      td_name: "profileTabGifs".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabGifsBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabGifsBuilder {
  inner: ProfileTabGifs,
}

impl RTDProfileTabGifsBuilder {
  pub fn build(&self) -> ProfileTabGifs {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabGifs> for ProfileTabGifs {
  fn as_ref(&self) -> &ProfileTabGifs {
    self
  }
}

impl AsRef<ProfileTabGifs> for RTDProfileTabGifsBuilder {
  fn as_ref(&self) -> &ProfileTabGifs {
    &self.inner
  }
}

/// A tab with gifts received by the user or the channel chat
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabGifts {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabGifts {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabGifts"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabGifts {}

impl ProfileTabGifts {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabGiftsBuilder {
    let inner = ProfileTabGifts {
      td_name: "profileTabGifts".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabGiftsBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabGiftsBuilder {
  inner: ProfileTabGifts,
}

impl RTDProfileTabGiftsBuilder {
  pub fn build(&self) -> ProfileTabGifts {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabGifts> for ProfileTabGifts {
  fn as_ref(&self) -> &ProfileTabGifts {
    self
  }
}

impl AsRef<ProfileTabGifts> for RTDProfileTabGiftsBuilder {
  fn as_ref(&self) -> &ProfileTabGifts {
    &self.inner
  }
}

/// A tab with messages posted by the channel and containing links
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabLinks {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabLinks {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabLinks"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabLinks {}

impl ProfileTabLinks {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabLinksBuilder {
    let inner = ProfileTabLinks {
      td_name: "profileTabLinks".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabLinksBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabLinksBuilder {
  inner: ProfileTabLinks,
}

impl RTDProfileTabLinksBuilder {
  pub fn build(&self) -> ProfileTabLinks {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabLinks> for ProfileTabLinks {
  fn as_ref(&self) -> &ProfileTabLinks {
    self
  }
}

impl AsRef<ProfileTabLinks> for RTDProfileTabLinksBuilder {
  fn as_ref(&self) -> &ProfileTabLinks {
    &self.inner
  }
}

/// A tab with photos and videos posted by the channel
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabMedia {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabMedia {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabMedia"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabMedia {}

impl ProfileTabMedia {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabMediaBuilder {
    let inner = ProfileTabMedia {
      td_name: "profileTabMedia".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabMediaBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabMediaBuilder {
  inner: ProfileTabMedia,
}

impl RTDProfileTabMediaBuilder {
  pub fn build(&self) -> ProfileTabMedia {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabMedia> for ProfileTabMedia {
  fn as_ref(&self) -> &ProfileTabMedia {
    self
  }
}

impl AsRef<ProfileTabMedia> for RTDProfileTabMediaBuilder {
  fn as_ref(&self) -> &ProfileTabMedia {
    &self.inner
  }
}

/// A tab with audio messages posted by the channel
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabMusic {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabMusic {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabMusic"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabMusic {}

impl ProfileTabMusic {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabMusicBuilder {
    let inner = ProfileTabMusic {
      td_name: "profileTabMusic".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabMusicBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabMusicBuilder {
  inner: ProfileTabMusic,
}

impl RTDProfileTabMusicBuilder {
  pub fn build(&self) -> ProfileTabMusic {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabMusic> for ProfileTabMusic {
  fn as_ref(&self) -> &ProfileTabMusic {
    self
  }
}

impl AsRef<ProfileTabMusic> for RTDProfileTabMusicBuilder {
  fn as_ref(&self) -> &ProfileTabMusic {
    &self.inner
  }
}

/// A tab with stories posted by the user or the channel chat and saved to profile
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabPosts {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabPosts {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabPosts"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabPosts {}

impl ProfileTabPosts {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabPostsBuilder {
    let inner = ProfileTabPosts {
      td_name: "profileTabPosts".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabPostsBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabPostsBuilder {
  inner: ProfileTabPosts,
}

impl RTDProfileTabPostsBuilder {
  pub fn build(&self) -> ProfileTabPosts {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabPosts> for ProfileTabPosts {
  fn as_ref(&self) -> &ProfileTabPosts {
    self
  }
}

impl AsRef<ProfileTabPosts> for RTDProfileTabPostsBuilder {
  fn as_ref(&self) -> &ProfileTabPosts {
    &self.inner
  }
}

/// A tab with voice notes posted by the channel
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ProfileTabVoice {
  #[doc(hidden)]
  #[serde(rename(serialize = "@type", deserialize = "@type"))]
  td_name: String,
  #[doc(hidden)]
  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
  extra: Option<String>,
}

impl RObject for ProfileTabVoice {
  #[doc(hidden)]
  fn td_name(&self) -> &'static str {
    "profileTabVoice"
  }
  #[doc(hidden)]
  fn extra(&self) -> Option<String> {
    self.extra.clone()
  }
  fn to_json(&self) -> RTDResult<String> {
    Ok(serde_json::to_string(self)?)
  }
}

impl TDProfileTab for ProfileTabVoice {}

impl ProfileTabVoice {
  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
    Ok(serde_json::from_str(json.as_ref())?)
  }
  pub fn builder() -> RTDProfileTabVoiceBuilder {
    let inner = ProfileTabVoice {
      td_name: "profileTabVoice".to_string(),
      extra: Some(Uuid::new_v4().to_string()),
    };
    RTDProfileTabVoiceBuilder { inner }
  }
}

#[doc(hidden)]
pub struct RTDProfileTabVoiceBuilder {
  inner: ProfileTabVoice,
}

impl RTDProfileTabVoiceBuilder {
  pub fn build(&self) -> ProfileTabVoice {
    self.inner.clone()
  }
}

impl AsRef<ProfileTabVoice> for ProfileTabVoice {
  fn as_ref(&self) -> &ProfileTabVoice {
    self
  }
}

impl AsRef<ProfileTabVoice> for RTDProfileTabVoiceBuilder {
  fn as_ref(&self) -> &ProfileTabVoice {
    &self.inner
  }
}