rust_tdlib/types/
chat_action.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Describes the different types of activity in a chat
8pub trait TDChatAction: Debug + RObject {}
9
10/// Describes the different types of activity in a chat
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum ChatAction {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// The user has canceled the previous action
18    #[serde(rename = "chatActionCancel")]
19    Cancel(ChatActionCancel),
20    /// The user is picking a contact to send
21    #[serde(rename = "chatActionChoosingContact")]
22    ChoosingContact(ChatActionChoosingContact),
23    /// The user is picking a location or venue to send
24    #[serde(rename = "chatActionChoosingLocation")]
25    ChoosingLocation(ChatActionChoosingLocation),
26    /// The user is picking a sticker to send
27    #[serde(rename = "chatActionChoosingSticker")]
28    ChoosingSticker(ChatActionChoosingSticker),
29    /// The user is recording a video
30    #[serde(rename = "chatActionRecordingVideo")]
31    RecordingVideo(ChatActionRecordingVideo),
32    /// The user is recording a video note
33    #[serde(rename = "chatActionRecordingVideoNote")]
34    RecordingVideoNote(ChatActionRecordingVideoNote),
35    /// The user is recording a voice note
36    #[serde(rename = "chatActionRecordingVoiceNote")]
37    RecordingVoiceNote(ChatActionRecordingVoiceNote),
38    /// The user has started to play a game
39    #[serde(rename = "chatActionStartPlayingGame")]
40    StartPlayingGame(ChatActionStartPlayingGame),
41    /// The user is typing a message
42    #[serde(rename = "chatActionTyping")]
43    Typing(ChatActionTyping),
44    /// The user is uploading a document
45    #[serde(rename = "chatActionUploadingDocument")]
46    UploadingDocument(ChatActionUploadingDocument),
47    /// The user is uploading a photo
48    #[serde(rename = "chatActionUploadingPhoto")]
49    UploadingPhoto(ChatActionUploadingPhoto),
50    /// The user is uploading a video
51    #[serde(rename = "chatActionUploadingVideo")]
52    UploadingVideo(ChatActionUploadingVideo),
53    /// The user is uploading a video note
54    #[serde(rename = "chatActionUploadingVideoNote")]
55    UploadingVideoNote(ChatActionUploadingVideoNote),
56    /// The user is uploading a voice note
57    #[serde(rename = "chatActionUploadingVoiceNote")]
58    UploadingVoiceNote(ChatActionUploadingVoiceNote),
59    /// The user is watching animations sent by the other party by clicking on an animated emoji
60    #[serde(rename = "chatActionWatchingAnimations")]
61    WatchingAnimations(ChatActionWatchingAnimations),
62}
63
64impl RObject for ChatAction {
65    #[doc(hidden)]
66    fn extra(&self) -> Option<&str> {
67        match self {
68            ChatAction::Cancel(t) => t.extra(),
69            ChatAction::ChoosingContact(t) => t.extra(),
70            ChatAction::ChoosingLocation(t) => t.extra(),
71            ChatAction::ChoosingSticker(t) => t.extra(),
72            ChatAction::RecordingVideo(t) => t.extra(),
73            ChatAction::RecordingVideoNote(t) => t.extra(),
74            ChatAction::RecordingVoiceNote(t) => t.extra(),
75            ChatAction::StartPlayingGame(t) => t.extra(),
76            ChatAction::Typing(t) => t.extra(),
77            ChatAction::UploadingDocument(t) => t.extra(),
78            ChatAction::UploadingPhoto(t) => t.extra(),
79            ChatAction::UploadingVideo(t) => t.extra(),
80            ChatAction::UploadingVideoNote(t) => t.extra(),
81            ChatAction::UploadingVoiceNote(t) => t.extra(),
82            ChatAction::WatchingAnimations(t) => t.extra(),
83
84            _ => None,
85        }
86    }
87    #[doc(hidden)]
88    fn client_id(&self) -> Option<i32> {
89        match self {
90            ChatAction::Cancel(t) => t.client_id(),
91            ChatAction::ChoosingContact(t) => t.client_id(),
92            ChatAction::ChoosingLocation(t) => t.client_id(),
93            ChatAction::ChoosingSticker(t) => t.client_id(),
94            ChatAction::RecordingVideo(t) => t.client_id(),
95            ChatAction::RecordingVideoNote(t) => t.client_id(),
96            ChatAction::RecordingVoiceNote(t) => t.client_id(),
97            ChatAction::StartPlayingGame(t) => t.client_id(),
98            ChatAction::Typing(t) => t.client_id(),
99            ChatAction::UploadingDocument(t) => t.client_id(),
100            ChatAction::UploadingPhoto(t) => t.client_id(),
101            ChatAction::UploadingVideo(t) => t.client_id(),
102            ChatAction::UploadingVideoNote(t) => t.client_id(),
103            ChatAction::UploadingVoiceNote(t) => t.client_id(),
104            ChatAction::WatchingAnimations(t) => t.client_id(),
105
106            _ => None,
107        }
108    }
109}
110
111impl ChatAction {
112    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
113        Ok(serde_json::from_str(json.as_ref())?)
114    }
115    #[doc(hidden)]
116    pub fn _is_default(&self) -> bool {
117        matches!(self, ChatAction::_Default)
118    }
119}
120
121impl AsRef<ChatAction> for ChatAction {
122    fn as_ref(&self) -> &ChatAction {
123        self
124    }
125}
126
127/// The user has canceled the previous action
128#[derive(Debug, Clone, Default, Serialize, Deserialize)]
129pub struct ChatActionCancel {
130    #[doc(hidden)]
131    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
132    extra: Option<String>,
133    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
134    client_id: Option<i32>,
135}
136
137impl RObject for ChatActionCancel {
138    #[doc(hidden)]
139    fn extra(&self) -> Option<&str> {
140        self.extra.as_deref()
141    }
142    #[doc(hidden)]
143    fn client_id(&self) -> Option<i32> {
144        self.client_id
145    }
146}
147
148impl TDChatAction for ChatActionCancel {}
149
150impl ChatActionCancel {
151    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
152        Ok(serde_json::from_str(json.as_ref())?)
153    }
154    pub fn builder() -> ChatActionCancelBuilder {
155        let mut inner = ChatActionCancel::default();
156        inner.extra = Some(Uuid::new_v4().to_string());
157
158        ChatActionCancelBuilder { inner }
159    }
160}
161
162#[doc(hidden)]
163pub struct ChatActionCancelBuilder {
164    inner: ChatActionCancel,
165}
166
167#[deprecated]
168pub type RTDChatActionCancelBuilder = ChatActionCancelBuilder;
169
170impl ChatActionCancelBuilder {
171    pub fn build(&self) -> ChatActionCancel {
172        self.inner.clone()
173    }
174}
175
176impl AsRef<ChatActionCancel> for ChatActionCancel {
177    fn as_ref(&self) -> &ChatActionCancel {
178        self
179    }
180}
181
182impl AsRef<ChatActionCancel> for ChatActionCancelBuilder {
183    fn as_ref(&self) -> &ChatActionCancel {
184        &self.inner
185    }
186}
187
188/// The user is picking a contact to send
189#[derive(Debug, Clone, Default, Serialize, Deserialize)]
190pub struct ChatActionChoosingContact {
191    #[doc(hidden)]
192    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
193    extra: Option<String>,
194    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
195    client_id: Option<i32>,
196}
197
198impl RObject for ChatActionChoosingContact {
199    #[doc(hidden)]
200    fn extra(&self) -> Option<&str> {
201        self.extra.as_deref()
202    }
203    #[doc(hidden)]
204    fn client_id(&self) -> Option<i32> {
205        self.client_id
206    }
207}
208
209impl TDChatAction for ChatActionChoosingContact {}
210
211impl ChatActionChoosingContact {
212    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
213        Ok(serde_json::from_str(json.as_ref())?)
214    }
215    pub fn builder() -> ChatActionChoosingContactBuilder {
216        let mut inner = ChatActionChoosingContact::default();
217        inner.extra = Some(Uuid::new_v4().to_string());
218
219        ChatActionChoosingContactBuilder { inner }
220    }
221}
222
223#[doc(hidden)]
224pub struct ChatActionChoosingContactBuilder {
225    inner: ChatActionChoosingContact,
226}
227
228#[deprecated]
229pub type RTDChatActionChoosingContactBuilder = ChatActionChoosingContactBuilder;
230
231impl ChatActionChoosingContactBuilder {
232    pub fn build(&self) -> ChatActionChoosingContact {
233        self.inner.clone()
234    }
235}
236
237impl AsRef<ChatActionChoosingContact> for ChatActionChoosingContact {
238    fn as_ref(&self) -> &ChatActionChoosingContact {
239        self
240    }
241}
242
243impl AsRef<ChatActionChoosingContact> for ChatActionChoosingContactBuilder {
244    fn as_ref(&self) -> &ChatActionChoosingContact {
245        &self.inner
246    }
247}
248
249/// The user is picking a location or venue to send
250#[derive(Debug, Clone, Default, Serialize, Deserialize)]
251pub struct ChatActionChoosingLocation {
252    #[doc(hidden)]
253    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
254    extra: Option<String>,
255    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
256    client_id: Option<i32>,
257}
258
259impl RObject for ChatActionChoosingLocation {
260    #[doc(hidden)]
261    fn extra(&self) -> Option<&str> {
262        self.extra.as_deref()
263    }
264    #[doc(hidden)]
265    fn client_id(&self) -> Option<i32> {
266        self.client_id
267    }
268}
269
270impl TDChatAction for ChatActionChoosingLocation {}
271
272impl ChatActionChoosingLocation {
273    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
274        Ok(serde_json::from_str(json.as_ref())?)
275    }
276    pub fn builder() -> ChatActionChoosingLocationBuilder {
277        let mut inner = ChatActionChoosingLocation::default();
278        inner.extra = Some(Uuid::new_v4().to_string());
279
280        ChatActionChoosingLocationBuilder { inner }
281    }
282}
283
284#[doc(hidden)]
285pub struct ChatActionChoosingLocationBuilder {
286    inner: ChatActionChoosingLocation,
287}
288
289#[deprecated]
290pub type RTDChatActionChoosingLocationBuilder = ChatActionChoosingLocationBuilder;
291
292impl ChatActionChoosingLocationBuilder {
293    pub fn build(&self) -> ChatActionChoosingLocation {
294        self.inner.clone()
295    }
296}
297
298impl AsRef<ChatActionChoosingLocation> for ChatActionChoosingLocation {
299    fn as_ref(&self) -> &ChatActionChoosingLocation {
300        self
301    }
302}
303
304impl AsRef<ChatActionChoosingLocation> for ChatActionChoosingLocationBuilder {
305    fn as_ref(&self) -> &ChatActionChoosingLocation {
306        &self.inner
307    }
308}
309
310/// The user is picking a sticker to send
311#[derive(Debug, Clone, Default, Serialize, Deserialize)]
312pub struct ChatActionChoosingSticker {
313    #[doc(hidden)]
314    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
315    extra: Option<String>,
316    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
317    client_id: Option<i32>,
318}
319
320impl RObject for ChatActionChoosingSticker {
321    #[doc(hidden)]
322    fn extra(&self) -> Option<&str> {
323        self.extra.as_deref()
324    }
325    #[doc(hidden)]
326    fn client_id(&self) -> Option<i32> {
327        self.client_id
328    }
329}
330
331impl TDChatAction for ChatActionChoosingSticker {}
332
333impl ChatActionChoosingSticker {
334    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
335        Ok(serde_json::from_str(json.as_ref())?)
336    }
337    pub fn builder() -> ChatActionChoosingStickerBuilder {
338        let mut inner = ChatActionChoosingSticker::default();
339        inner.extra = Some(Uuid::new_v4().to_string());
340
341        ChatActionChoosingStickerBuilder { inner }
342    }
343}
344
345#[doc(hidden)]
346pub struct ChatActionChoosingStickerBuilder {
347    inner: ChatActionChoosingSticker,
348}
349
350#[deprecated]
351pub type RTDChatActionChoosingStickerBuilder = ChatActionChoosingStickerBuilder;
352
353impl ChatActionChoosingStickerBuilder {
354    pub fn build(&self) -> ChatActionChoosingSticker {
355        self.inner.clone()
356    }
357}
358
359impl AsRef<ChatActionChoosingSticker> for ChatActionChoosingSticker {
360    fn as_ref(&self) -> &ChatActionChoosingSticker {
361        self
362    }
363}
364
365impl AsRef<ChatActionChoosingSticker> for ChatActionChoosingStickerBuilder {
366    fn as_ref(&self) -> &ChatActionChoosingSticker {
367        &self.inner
368    }
369}
370
371/// The user is recording a video
372#[derive(Debug, Clone, Default, Serialize, Deserialize)]
373pub struct ChatActionRecordingVideo {
374    #[doc(hidden)]
375    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
376    extra: Option<String>,
377    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
378    client_id: Option<i32>,
379}
380
381impl RObject for ChatActionRecordingVideo {
382    #[doc(hidden)]
383    fn extra(&self) -> Option<&str> {
384        self.extra.as_deref()
385    }
386    #[doc(hidden)]
387    fn client_id(&self) -> Option<i32> {
388        self.client_id
389    }
390}
391
392impl TDChatAction for ChatActionRecordingVideo {}
393
394impl ChatActionRecordingVideo {
395    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
396        Ok(serde_json::from_str(json.as_ref())?)
397    }
398    pub fn builder() -> ChatActionRecordingVideoBuilder {
399        let mut inner = ChatActionRecordingVideo::default();
400        inner.extra = Some(Uuid::new_v4().to_string());
401
402        ChatActionRecordingVideoBuilder { inner }
403    }
404}
405
406#[doc(hidden)]
407pub struct ChatActionRecordingVideoBuilder {
408    inner: ChatActionRecordingVideo,
409}
410
411#[deprecated]
412pub type RTDChatActionRecordingVideoBuilder = ChatActionRecordingVideoBuilder;
413
414impl ChatActionRecordingVideoBuilder {
415    pub fn build(&self) -> ChatActionRecordingVideo {
416        self.inner.clone()
417    }
418}
419
420impl AsRef<ChatActionRecordingVideo> for ChatActionRecordingVideo {
421    fn as_ref(&self) -> &ChatActionRecordingVideo {
422        self
423    }
424}
425
426impl AsRef<ChatActionRecordingVideo> for ChatActionRecordingVideoBuilder {
427    fn as_ref(&self) -> &ChatActionRecordingVideo {
428        &self.inner
429    }
430}
431
432/// The user is recording a video note
433#[derive(Debug, Clone, Default, Serialize, Deserialize)]
434pub struct ChatActionRecordingVideoNote {
435    #[doc(hidden)]
436    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
437    extra: Option<String>,
438    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
439    client_id: Option<i32>,
440}
441
442impl RObject for ChatActionRecordingVideoNote {
443    #[doc(hidden)]
444    fn extra(&self) -> Option<&str> {
445        self.extra.as_deref()
446    }
447    #[doc(hidden)]
448    fn client_id(&self) -> Option<i32> {
449        self.client_id
450    }
451}
452
453impl TDChatAction for ChatActionRecordingVideoNote {}
454
455impl ChatActionRecordingVideoNote {
456    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
457        Ok(serde_json::from_str(json.as_ref())?)
458    }
459    pub fn builder() -> ChatActionRecordingVideoNoteBuilder {
460        let mut inner = ChatActionRecordingVideoNote::default();
461        inner.extra = Some(Uuid::new_v4().to_string());
462
463        ChatActionRecordingVideoNoteBuilder { inner }
464    }
465}
466
467#[doc(hidden)]
468pub struct ChatActionRecordingVideoNoteBuilder {
469    inner: ChatActionRecordingVideoNote,
470}
471
472#[deprecated]
473pub type RTDChatActionRecordingVideoNoteBuilder = ChatActionRecordingVideoNoteBuilder;
474
475impl ChatActionRecordingVideoNoteBuilder {
476    pub fn build(&self) -> ChatActionRecordingVideoNote {
477        self.inner.clone()
478    }
479}
480
481impl AsRef<ChatActionRecordingVideoNote> for ChatActionRecordingVideoNote {
482    fn as_ref(&self) -> &ChatActionRecordingVideoNote {
483        self
484    }
485}
486
487impl AsRef<ChatActionRecordingVideoNote> for ChatActionRecordingVideoNoteBuilder {
488    fn as_ref(&self) -> &ChatActionRecordingVideoNote {
489        &self.inner
490    }
491}
492
493/// The user is recording a voice note
494#[derive(Debug, Clone, Default, Serialize, Deserialize)]
495pub struct ChatActionRecordingVoiceNote {
496    #[doc(hidden)]
497    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
498    extra: Option<String>,
499    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
500    client_id: Option<i32>,
501}
502
503impl RObject for ChatActionRecordingVoiceNote {
504    #[doc(hidden)]
505    fn extra(&self) -> Option<&str> {
506        self.extra.as_deref()
507    }
508    #[doc(hidden)]
509    fn client_id(&self) -> Option<i32> {
510        self.client_id
511    }
512}
513
514impl TDChatAction for ChatActionRecordingVoiceNote {}
515
516impl ChatActionRecordingVoiceNote {
517    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
518        Ok(serde_json::from_str(json.as_ref())?)
519    }
520    pub fn builder() -> ChatActionRecordingVoiceNoteBuilder {
521        let mut inner = ChatActionRecordingVoiceNote::default();
522        inner.extra = Some(Uuid::new_v4().to_string());
523
524        ChatActionRecordingVoiceNoteBuilder { inner }
525    }
526}
527
528#[doc(hidden)]
529pub struct ChatActionRecordingVoiceNoteBuilder {
530    inner: ChatActionRecordingVoiceNote,
531}
532
533#[deprecated]
534pub type RTDChatActionRecordingVoiceNoteBuilder = ChatActionRecordingVoiceNoteBuilder;
535
536impl ChatActionRecordingVoiceNoteBuilder {
537    pub fn build(&self) -> ChatActionRecordingVoiceNote {
538        self.inner.clone()
539    }
540}
541
542impl AsRef<ChatActionRecordingVoiceNote> for ChatActionRecordingVoiceNote {
543    fn as_ref(&self) -> &ChatActionRecordingVoiceNote {
544        self
545    }
546}
547
548impl AsRef<ChatActionRecordingVoiceNote> for ChatActionRecordingVoiceNoteBuilder {
549    fn as_ref(&self) -> &ChatActionRecordingVoiceNote {
550        &self.inner
551    }
552}
553
554/// The user has started to play a game
555#[derive(Debug, Clone, Default, Serialize, Deserialize)]
556pub struct ChatActionStartPlayingGame {
557    #[doc(hidden)]
558    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
559    extra: Option<String>,
560    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
561    client_id: Option<i32>,
562}
563
564impl RObject for ChatActionStartPlayingGame {
565    #[doc(hidden)]
566    fn extra(&self) -> Option<&str> {
567        self.extra.as_deref()
568    }
569    #[doc(hidden)]
570    fn client_id(&self) -> Option<i32> {
571        self.client_id
572    }
573}
574
575impl TDChatAction for ChatActionStartPlayingGame {}
576
577impl ChatActionStartPlayingGame {
578    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
579        Ok(serde_json::from_str(json.as_ref())?)
580    }
581    pub fn builder() -> ChatActionStartPlayingGameBuilder {
582        let mut inner = ChatActionStartPlayingGame::default();
583        inner.extra = Some(Uuid::new_v4().to_string());
584
585        ChatActionStartPlayingGameBuilder { inner }
586    }
587}
588
589#[doc(hidden)]
590pub struct ChatActionStartPlayingGameBuilder {
591    inner: ChatActionStartPlayingGame,
592}
593
594#[deprecated]
595pub type RTDChatActionStartPlayingGameBuilder = ChatActionStartPlayingGameBuilder;
596
597impl ChatActionStartPlayingGameBuilder {
598    pub fn build(&self) -> ChatActionStartPlayingGame {
599        self.inner.clone()
600    }
601}
602
603impl AsRef<ChatActionStartPlayingGame> for ChatActionStartPlayingGame {
604    fn as_ref(&self) -> &ChatActionStartPlayingGame {
605        self
606    }
607}
608
609impl AsRef<ChatActionStartPlayingGame> for ChatActionStartPlayingGameBuilder {
610    fn as_ref(&self) -> &ChatActionStartPlayingGame {
611        &self.inner
612    }
613}
614
615/// The user is typing a message
616#[derive(Debug, Clone, Default, Serialize, Deserialize)]
617pub struct ChatActionTyping {
618    #[doc(hidden)]
619    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
620    extra: Option<String>,
621    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
622    client_id: Option<i32>,
623}
624
625impl RObject for ChatActionTyping {
626    #[doc(hidden)]
627    fn extra(&self) -> Option<&str> {
628        self.extra.as_deref()
629    }
630    #[doc(hidden)]
631    fn client_id(&self) -> Option<i32> {
632        self.client_id
633    }
634}
635
636impl TDChatAction for ChatActionTyping {}
637
638impl ChatActionTyping {
639    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
640        Ok(serde_json::from_str(json.as_ref())?)
641    }
642    pub fn builder() -> ChatActionTypingBuilder {
643        let mut inner = ChatActionTyping::default();
644        inner.extra = Some(Uuid::new_v4().to_string());
645
646        ChatActionTypingBuilder { inner }
647    }
648}
649
650#[doc(hidden)]
651pub struct ChatActionTypingBuilder {
652    inner: ChatActionTyping,
653}
654
655#[deprecated]
656pub type RTDChatActionTypingBuilder = ChatActionTypingBuilder;
657
658impl ChatActionTypingBuilder {
659    pub fn build(&self) -> ChatActionTyping {
660        self.inner.clone()
661    }
662}
663
664impl AsRef<ChatActionTyping> for ChatActionTyping {
665    fn as_ref(&self) -> &ChatActionTyping {
666        self
667    }
668}
669
670impl AsRef<ChatActionTyping> for ChatActionTypingBuilder {
671    fn as_ref(&self) -> &ChatActionTyping {
672        &self.inner
673    }
674}
675
676/// The user is uploading a document
677#[derive(Debug, Clone, Default, Serialize, Deserialize)]
678pub struct ChatActionUploadingDocument {
679    #[doc(hidden)]
680    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
681    extra: Option<String>,
682    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
683    client_id: Option<i32>,
684    /// Upload progress, as a percentage
685
686    #[serde(default)]
687    progress: i32,
688}
689
690impl RObject for ChatActionUploadingDocument {
691    #[doc(hidden)]
692    fn extra(&self) -> Option<&str> {
693        self.extra.as_deref()
694    }
695    #[doc(hidden)]
696    fn client_id(&self) -> Option<i32> {
697        self.client_id
698    }
699}
700
701impl TDChatAction for ChatActionUploadingDocument {}
702
703impl ChatActionUploadingDocument {
704    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
705        Ok(serde_json::from_str(json.as_ref())?)
706    }
707    pub fn builder() -> ChatActionUploadingDocumentBuilder {
708        let mut inner = ChatActionUploadingDocument::default();
709        inner.extra = Some(Uuid::new_v4().to_string());
710
711        ChatActionUploadingDocumentBuilder { inner }
712    }
713
714    pub fn progress(&self) -> i32 {
715        self.progress
716    }
717}
718
719#[doc(hidden)]
720pub struct ChatActionUploadingDocumentBuilder {
721    inner: ChatActionUploadingDocument,
722}
723
724#[deprecated]
725pub type RTDChatActionUploadingDocumentBuilder = ChatActionUploadingDocumentBuilder;
726
727impl ChatActionUploadingDocumentBuilder {
728    pub fn build(&self) -> ChatActionUploadingDocument {
729        self.inner.clone()
730    }
731
732    pub fn progress(&mut self, progress: i32) -> &mut Self {
733        self.inner.progress = progress;
734        self
735    }
736}
737
738impl AsRef<ChatActionUploadingDocument> for ChatActionUploadingDocument {
739    fn as_ref(&self) -> &ChatActionUploadingDocument {
740        self
741    }
742}
743
744impl AsRef<ChatActionUploadingDocument> for ChatActionUploadingDocumentBuilder {
745    fn as_ref(&self) -> &ChatActionUploadingDocument {
746        &self.inner
747    }
748}
749
750/// The user is uploading a photo
751#[derive(Debug, Clone, Default, Serialize, Deserialize)]
752pub struct ChatActionUploadingPhoto {
753    #[doc(hidden)]
754    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
755    extra: Option<String>,
756    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
757    client_id: Option<i32>,
758    /// Upload progress, as a percentage
759
760    #[serde(default)]
761    progress: i32,
762}
763
764impl RObject for ChatActionUploadingPhoto {
765    #[doc(hidden)]
766    fn extra(&self) -> Option<&str> {
767        self.extra.as_deref()
768    }
769    #[doc(hidden)]
770    fn client_id(&self) -> Option<i32> {
771        self.client_id
772    }
773}
774
775impl TDChatAction for ChatActionUploadingPhoto {}
776
777impl ChatActionUploadingPhoto {
778    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
779        Ok(serde_json::from_str(json.as_ref())?)
780    }
781    pub fn builder() -> ChatActionUploadingPhotoBuilder {
782        let mut inner = ChatActionUploadingPhoto::default();
783        inner.extra = Some(Uuid::new_v4().to_string());
784
785        ChatActionUploadingPhotoBuilder { inner }
786    }
787
788    pub fn progress(&self) -> i32 {
789        self.progress
790    }
791}
792
793#[doc(hidden)]
794pub struct ChatActionUploadingPhotoBuilder {
795    inner: ChatActionUploadingPhoto,
796}
797
798#[deprecated]
799pub type RTDChatActionUploadingPhotoBuilder = ChatActionUploadingPhotoBuilder;
800
801impl ChatActionUploadingPhotoBuilder {
802    pub fn build(&self) -> ChatActionUploadingPhoto {
803        self.inner.clone()
804    }
805
806    pub fn progress(&mut self, progress: i32) -> &mut Self {
807        self.inner.progress = progress;
808        self
809    }
810}
811
812impl AsRef<ChatActionUploadingPhoto> for ChatActionUploadingPhoto {
813    fn as_ref(&self) -> &ChatActionUploadingPhoto {
814        self
815    }
816}
817
818impl AsRef<ChatActionUploadingPhoto> for ChatActionUploadingPhotoBuilder {
819    fn as_ref(&self) -> &ChatActionUploadingPhoto {
820        &self.inner
821    }
822}
823
824/// The user is uploading a video
825#[derive(Debug, Clone, Default, Serialize, Deserialize)]
826pub struct ChatActionUploadingVideo {
827    #[doc(hidden)]
828    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
829    extra: Option<String>,
830    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
831    client_id: Option<i32>,
832    /// Upload progress, as a percentage
833
834    #[serde(default)]
835    progress: i32,
836}
837
838impl RObject for ChatActionUploadingVideo {
839    #[doc(hidden)]
840    fn extra(&self) -> Option<&str> {
841        self.extra.as_deref()
842    }
843    #[doc(hidden)]
844    fn client_id(&self) -> Option<i32> {
845        self.client_id
846    }
847}
848
849impl TDChatAction for ChatActionUploadingVideo {}
850
851impl ChatActionUploadingVideo {
852    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
853        Ok(serde_json::from_str(json.as_ref())?)
854    }
855    pub fn builder() -> ChatActionUploadingVideoBuilder {
856        let mut inner = ChatActionUploadingVideo::default();
857        inner.extra = Some(Uuid::new_v4().to_string());
858
859        ChatActionUploadingVideoBuilder { inner }
860    }
861
862    pub fn progress(&self) -> i32 {
863        self.progress
864    }
865}
866
867#[doc(hidden)]
868pub struct ChatActionUploadingVideoBuilder {
869    inner: ChatActionUploadingVideo,
870}
871
872#[deprecated]
873pub type RTDChatActionUploadingVideoBuilder = ChatActionUploadingVideoBuilder;
874
875impl ChatActionUploadingVideoBuilder {
876    pub fn build(&self) -> ChatActionUploadingVideo {
877        self.inner.clone()
878    }
879
880    pub fn progress(&mut self, progress: i32) -> &mut Self {
881        self.inner.progress = progress;
882        self
883    }
884}
885
886impl AsRef<ChatActionUploadingVideo> for ChatActionUploadingVideo {
887    fn as_ref(&self) -> &ChatActionUploadingVideo {
888        self
889    }
890}
891
892impl AsRef<ChatActionUploadingVideo> for ChatActionUploadingVideoBuilder {
893    fn as_ref(&self) -> &ChatActionUploadingVideo {
894        &self.inner
895    }
896}
897
898/// The user is uploading a video note
899#[derive(Debug, Clone, Default, Serialize, Deserialize)]
900pub struct ChatActionUploadingVideoNote {
901    #[doc(hidden)]
902    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
903    extra: Option<String>,
904    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
905    client_id: Option<i32>,
906    /// Upload progress, as a percentage
907
908    #[serde(default)]
909    progress: i32,
910}
911
912impl RObject for ChatActionUploadingVideoNote {
913    #[doc(hidden)]
914    fn extra(&self) -> Option<&str> {
915        self.extra.as_deref()
916    }
917    #[doc(hidden)]
918    fn client_id(&self) -> Option<i32> {
919        self.client_id
920    }
921}
922
923impl TDChatAction for ChatActionUploadingVideoNote {}
924
925impl ChatActionUploadingVideoNote {
926    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
927        Ok(serde_json::from_str(json.as_ref())?)
928    }
929    pub fn builder() -> ChatActionUploadingVideoNoteBuilder {
930        let mut inner = ChatActionUploadingVideoNote::default();
931        inner.extra = Some(Uuid::new_v4().to_string());
932
933        ChatActionUploadingVideoNoteBuilder { inner }
934    }
935
936    pub fn progress(&self) -> i32 {
937        self.progress
938    }
939}
940
941#[doc(hidden)]
942pub struct ChatActionUploadingVideoNoteBuilder {
943    inner: ChatActionUploadingVideoNote,
944}
945
946#[deprecated]
947pub type RTDChatActionUploadingVideoNoteBuilder = ChatActionUploadingVideoNoteBuilder;
948
949impl ChatActionUploadingVideoNoteBuilder {
950    pub fn build(&self) -> ChatActionUploadingVideoNote {
951        self.inner.clone()
952    }
953
954    pub fn progress(&mut self, progress: i32) -> &mut Self {
955        self.inner.progress = progress;
956        self
957    }
958}
959
960impl AsRef<ChatActionUploadingVideoNote> for ChatActionUploadingVideoNote {
961    fn as_ref(&self) -> &ChatActionUploadingVideoNote {
962        self
963    }
964}
965
966impl AsRef<ChatActionUploadingVideoNote> for ChatActionUploadingVideoNoteBuilder {
967    fn as_ref(&self) -> &ChatActionUploadingVideoNote {
968        &self.inner
969    }
970}
971
972/// The user is uploading a voice note
973#[derive(Debug, Clone, Default, Serialize, Deserialize)]
974pub struct ChatActionUploadingVoiceNote {
975    #[doc(hidden)]
976    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
977    extra: Option<String>,
978    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
979    client_id: Option<i32>,
980    /// Upload progress, as a percentage
981
982    #[serde(default)]
983    progress: i32,
984}
985
986impl RObject for ChatActionUploadingVoiceNote {
987    #[doc(hidden)]
988    fn extra(&self) -> Option<&str> {
989        self.extra.as_deref()
990    }
991    #[doc(hidden)]
992    fn client_id(&self) -> Option<i32> {
993        self.client_id
994    }
995}
996
997impl TDChatAction for ChatActionUploadingVoiceNote {}
998
999impl ChatActionUploadingVoiceNote {
1000    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1001        Ok(serde_json::from_str(json.as_ref())?)
1002    }
1003    pub fn builder() -> ChatActionUploadingVoiceNoteBuilder {
1004        let mut inner = ChatActionUploadingVoiceNote::default();
1005        inner.extra = Some(Uuid::new_v4().to_string());
1006
1007        ChatActionUploadingVoiceNoteBuilder { inner }
1008    }
1009
1010    pub fn progress(&self) -> i32 {
1011        self.progress
1012    }
1013}
1014
1015#[doc(hidden)]
1016pub struct ChatActionUploadingVoiceNoteBuilder {
1017    inner: ChatActionUploadingVoiceNote,
1018}
1019
1020#[deprecated]
1021pub type RTDChatActionUploadingVoiceNoteBuilder = ChatActionUploadingVoiceNoteBuilder;
1022
1023impl ChatActionUploadingVoiceNoteBuilder {
1024    pub fn build(&self) -> ChatActionUploadingVoiceNote {
1025        self.inner.clone()
1026    }
1027
1028    pub fn progress(&mut self, progress: i32) -> &mut Self {
1029        self.inner.progress = progress;
1030        self
1031    }
1032}
1033
1034impl AsRef<ChatActionUploadingVoiceNote> for ChatActionUploadingVoiceNote {
1035    fn as_ref(&self) -> &ChatActionUploadingVoiceNote {
1036        self
1037    }
1038}
1039
1040impl AsRef<ChatActionUploadingVoiceNote> for ChatActionUploadingVoiceNoteBuilder {
1041    fn as_ref(&self) -> &ChatActionUploadingVoiceNote {
1042        &self.inner
1043    }
1044}
1045
1046/// The user is watching animations sent by the other party by clicking on an animated emoji
1047#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1048pub struct ChatActionWatchingAnimations {
1049    #[doc(hidden)]
1050    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1051    extra: Option<String>,
1052    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1053    client_id: Option<i32>,
1054    /// The animated emoji
1055
1056    #[serde(default)]
1057    emoji: String,
1058}
1059
1060impl RObject for ChatActionWatchingAnimations {
1061    #[doc(hidden)]
1062    fn extra(&self) -> Option<&str> {
1063        self.extra.as_deref()
1064    }
1065    #[doc(hidden)]
1066    fn client_id(&self) -> Option<i32> {
1067        self.client_id
1068    }
1069}
1070
1071impl TDChatAction for ChatActionWatchingAnimations {}
1072
1073impl ChatActionWatchingAnimations {
1074    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1075        Ok(serde_json::from_str(json.as_ref())?)
1076    }
1077    pub fn builder() -> ChatActionWatchingAnimationsBuilder {
1078        let mut inner = ChatActionWatchingAnimations::default();
1079        inner.extra = Some(Uuid::new_v4().to_string());
1080
1081        ChatActionWatchingAnimationsBuilder { inner }
1082    }
1083
1084    pub fn emoji(&self) -> &String {
1085        &self.emoji
1086    }
1087}
1088
1089#[doc(hidden)]
1090pub struct ChatActionWatchingAnimationsBuilder {
1091    inner: ChatActionWatchingAnimations,
1092}
1093
1094#[deprecated]
1095pub type RTDChatActionWatchingAnimationsBuilder = ChatActionWatchingAnimationsBuilder;
1096
1097impl ChatActionWatchingAnimationsBuilder {
1098    pub fn build(&self) -> ChatActionWatchingAnimations {
1099        self.inner.clone()
1100    }
1101
1102    pub fn emoji<T: AsRef<str>>(&mut self, emoji: T) -> &mut Self {
1103        self.inner.emoji = emoji.as_ref().to_string();
1104        self
1105    }
1106}
1107
1108impl AsRef<ChatActionWatchingAnimations> for ChatActionWatchingAnimations {
1109    fn as_ref(&self) -> &ChatActionWatchingAnimations {
1110        self
1111    }
1112}
1113
1114impl AsRef<ChatActionWatchingAnimations> for ChatActionWatchingAnimationsBuilder {
1115    fn as_ref(&self) -> &ChatActionWatchingAnimations {
1116        &self.inner
1117    }
1118}