rust_tdlib/types/
chat_report_reason.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Describes the reason why a chat is reported
8pub trait TDChatReportReason: Debug + RObject {}
9
10/// Describes the reason why a chat is reported
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum ChatReportReason {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// The chat has child abuse related content
18    #[serde(rename = "chatReportReasonChildAbuse")]
19    ChildAbuse(ChatReportReasonChildAbuse),
20    /// The chat contains copyrighted content
21    #[serde(rename = "chatReportReasonCopyright")]
22    Copyright(ChatReportReasonCopyright),
23    /// A custom reason provided by the user
24    #[serde(rename = "chatReportReasonCustom")]
25    Custom(ChatReportReasonCustom),
26    /// The chat represents a fake account
27    #[serde(rename = "chatReportReasonFake")]
28    Fake(ChatReportReasonFake),
29    /// The chat contains pornographic messages
30    #[serde(rename = "chatReportReasonPornography")]
31    Pornography(ChatReportReasonPornography),
32    /// The chat contains spam messages
33    #[serde(rename = "chatReportReasonSpam")]
34    Spam(ChatReportReasonSpam),
35    /// The location-based chat is unrelated to its stated location
36    #[serde(rename = "chatReportReasonUnrelatedLocation")]
37    UnrelatedLocation(ChatReportReasonUnrelatedLocation),
38    /// The chat promotes violence
39    #[serde(rename = "chatReportReasonViolence")]
40    Violence(ChatReportReasonViolence),
41}
42
43impl RObject for ChatReportReason {
44    #[doc(hidden)]
45    fn extra(&self) -> Option<&str> {
46        match self {
47            ChatReportReason::ChildAbuse(t) => t.extra(),
48            ChatReportReason::Copyright(t) => t.extra(),
49            ChatReportReason::Custom(t) => t.extra(),
50            ChatReportReason::Fake(t) => t.extra(),
51            ChatReportReason::Pornography(t) => t.extra(),
52            ChatReportReason::Spam(t) => t.extra(),
53            ChatReportReason::UnrelatedLocation(t) => t.extra(),
54            ChatReportReason::Violence(t) => t.extra(),
55
56            _ => None,
57        }
58    }
59    #[doc(hidden)]
60    fn client_id(&self) -> Option<i32> {
61        match self {
62            ChatReportReason::ChildAbuse(t) => t.client_id(),
63            ChatReportReason::Copyright(t) => t.client_id(),
64            ChatReportReason::Custom(t) => t.client_id(),
65            ChatReportReason::Fake(t) => t.client_id(),
66            ChatReportReason::Pornography(t) => t.client_id(),
67            ChatReportReason::Spam(t) => t.client_id(),
68            ChatReportReason::UnrelatedLocation(t) => t.client_id(),
69            ChatReportReason::Violence(t) => t.client_id(),
70
71            _ => None,
72        }
73    }
74}
75
76impl ChatReportReason {
77    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
78        Ok(serde_json::from_str(json.as_ref())?)
79    }
80    #[doc(hidden)]
81    pub fn _is_default(&self) -> bool {
82        matches!(self, ChatReportReason::_Default)
83    }
84}
85
86impl AsRef<ChatReportReason> for ChatReportReason {
87    fn as_ref(&self) -> &ChatReportReason {
88        self
89    }
90}
91
92/// The chat has child abuse related content
93#[derive(Debug, Clone, Default, Serialize, Deserialize)]
94pub struct ChatReportReasonChildAbuse {
95    #[doc(hidden)]
96    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
97    extra: Option<String>,
98    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
99    client_id: Option<i32>,
100}
101
102impl RObject for ChatReportReasonChildAbuse {
103    #[doc(hidden)]
104    fn extra(&self) -> Option<&str> {
105        self.extra.as_deref()
106    }
107    #[doc(hidden)]
108    fn client_id(&self) -> Option<i32> {
109        self.client_id
110    }
111}
112
113impl TDChatReportReason for ChatReportReasonChildAbuse {}
114
115impl ChatReportReasonChildAbuse {
116    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
117        Ok(serde_json::from_str(json.as_ref())?)
118    }
119    pub fn builder() -> ChatReportReasonChildAbuseBuilder {
120        let mut inner = ChatReportReasonChildAbuse::default();
121        inner.extra = Some(Uuid::new_v4().to_string());
122
123        ChatReportReasonChildAbuseBuilder { inner }
124    }
125}
126
127#[doc(hidden)]
128pub struct ChatReportReasonChildAbuseBuilder {
129    inner: ChatReportReasonChildAbuse,
130}
131
132#[deprecated]
133pub type RTDChatReportReasonChildAbuseBuilder = ChatReportReasonChildAbuseBuilder;
134
135impl ChatReportReasonChildAbuseBuilder {
136    pub fn build(&self) -> ChatReportReasonChildAbuse {
137        self.inner.clone()
138    }
139}
140
141impl AsRef<ChatReportReasonChildAbuse> for ChatReportReasonChildAbuse {
142    fn as_ref(&self) -> &ChatReportReasonChildAbuse {
143        self
144    }
145}
146
147impl AsRef<ChatReportReasonChildAbuse> for ChatReportReasonChildAbuseBuilder {
148    fn as_ref(&self) -> &ChatReportReasonChildAbuse {
149        &self.inner
150    }
151}
152
153/// The chat contains copyrighted content
154#[derive(Debug, Clone, Default, Serialize, Deserialize)]
155pub struct ChatReportReasonCopyright {
156    #[doc(hidden)]
157    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
158    extra: Option<String>,
159    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
160    client_id: Option<i32>,
161}
162
163impl RObject for ChatReportReasonCopyright {
164    #[doc(hidden)]
165    fn extra(&self) -> Option<&str> {
166        self.extra.as_deref()
167    }
168    #[doc(hidden)]
169    fn client_id(&self) -> Option<i32> {
170        self.client_id
171    }
172}
173
174impl TDChatReportReason for ChatReportReasonCopyright {}
175
176impl ChatReportReasonCopyright {
177    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
178        Ok(serde_json::from_str(json.as_ref())?)
179    }
180    pub fn builder() -> ChatReportReasonCopyrightBuilder {
181        let mut inner = ChatReportReasonCopyright::default();
182        inner.extra = Some(Uuid::new_v4().to_string());
183
184        ChatReportReasonCopyrightBuilder { inner }
185    }
186}
187
188#[doc(hidden)]
189pub struct ChatReportReasonCopyrightBuilder {
190    inner: ChatReportReasonCopyright,
191}
192
193#[deprecated]
194pub type RTDChatReportReasonCopyrightBuilder = ChatReportReasonCopyrightBuilder;
195
196impl ChatReportReasonCopyrightBuilder {
197    pub fn build(&self) -> ChatReportReasonCopyright {
198        self.inner.clone()
199    }
200}
201
202impl AsRef<ChatReportReasonCopyright> for ChatReportReasonCopyright {
203    fn as_ref(&self) -> &ChatReportReasonCopyright {
204        self
205    }
206}
207
208impl AsRef<ChatReportReasonCopyright> for ChatReportReasonCopyrightBuilder {
209    fn as_ref(&self) -> &ChatReportReasonCopyright {
210        &self.inner
211    }
212}
213
214/// A custom reason provided by the user
215#[derive(Debug, Clone, Default, Serialize, Deserialize)]
216pub struct ChatReportReasonCustom {
217    #[doc(hidden)]
218    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
219    extra: Option<String>,
220    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
221    client_id: Option<i32>,
222}
223
224impl RObject for ChatReportReasonCustom {
225    #[doc(hidden)]
226    fn extra(&self) -> Option<&str> {
227        self.extra.as_deref()
228    }
229    #[doc(hidden)]
230    fn client_id(&self) -> Option<i32> {
231        self.client_id
232    }
233}
234
235impl TDChatReportReason for ChatReportReasonCustom {}
236
237impl ChatReportReasonCustom {
238    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
239        Ok(serde_json::from_str(json.as_ref())?)
240    }
241    pub fn builder() -> ChatReportReasonCustomBuilder {
242        let mut inner = ChatReportReasonCustom::default();
243        inner.extra = Some(Uuid::new_v4().to_string());
244
245        ChatReportReasonCustomBuilder { inner }
246    }
247}
248
249#[doc(hidden)]
250pub struct ChatReportReasonCustomBuilder {
251    inner: ChatReportReasonCustom,
252}
253
254#[deprecated]
255pub type RTDChatReportReasonCustomBuilder = ChatReportReasonCustomBuilder;
256
257impl ChatReportReasonCustomBuilder {
258    pub fn build(&self) -> ChatReportReasonCustom {
259        self.inner.clone()
260    }
261}
262
263impl AsRef<ChatReportReasonCustom> for ChatReportReasonCustom {
264    fn as_ref(&self) -> &ChatReportReasonCustom {
265        self
266    }
267}
268
269impl AsRef<ChatReportReasonCustom> for ChatReportReasonCustomBuilder {
270    fn as_ref(&self) -> &ChatReportReasonCustom {
271        &self.inner
272    }
273}
274
275/// The chat represents a fake account
276#[derive(Debug, Clone, Default, Serialize, Deserialize)]
277pub struct ChatReportReasonFake {
278    #[doc(hidden)]
279    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
280    extra: Option<String>,
281    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
282    client_id: Option<i32>,
283}
284
285impl RObject for ChatReportReasonFake {
286    #[doc(hidden)]
287    fn extra(&self) -> Option<&str> {
288        self.extra.as_deref()
289    }
290    #[doc(hidden)]
291    fn client_id(&self) -> Option<i32> {
292        self.client_id
293    }
294}
295
296impl TDChatReportReason for ChatReportReasonFake {}
297
298impl ChatReportReasonFake {
299    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
300        Ok(serde_json::from_str(json.as_ref())?)
301    }
302    pub fn builder() -> ChatReportReasonFakeBuilder {
303        let mut inner = ChatReportReasonFake::default();
304        inner.extra = Some(Uuid::new_v4().to_string());
305
306        ChatReportReasonFakeBuilder { inner }
307    }
308}
309
310#[doc(hidden)]
311pub struct ChatReportReasonFakeBuilder {
312    inner: ChatReportReasonFake,
313}
314
315#[deprecated]
316pub type RTDChatReportReasonFakeBuilder = ChatReportReasonFakeBuilder;
317
318impl ChatReportReasonFakeBuilder {
319    pub fn build(&self) -> ChatReportReasonFake {
320        self.inner.clone()
321    }
322}
323
324impl AsRef<ChatReportReasonFake> for ChatReportReasonFake {
325    fn as_ref(&self) -> &ChatReportReasonFake {
326        self
327    }
328}
329
330impl AsRef<ChatReportReasonFake> for ChatReportReasonFakeBuilder {
331    fn as_ref(&self) -> &ChatReportReasonFake {
332        &self.inner
333    }
334}
335
336/// The chat contains pornographic messages
337#[derive(Debug, Clone, Default, Serialize, Deserialize)]
338pub struct ChatReportReasonPornography {
339    #[doc(hidden)]
340    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
341    extra: Option<String>,
342    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
343    client_id: Option<i32>,
344}
345
346impl RObject for ChatReportReasonPornography {
347    #[doc(hidden)]
348    fn extra(&self) -> Option<&str> {
349        self.extra.as_deref()
350    }
351    #[doc(hidden)]
352    fn client_id(&self) -> Option<i32> {
353        self.client_id
354    }
355}
356
357impl TDChatReportReason for ChatReportReasonPornography {}
358
359impl ChatReportReasonPornography {
360    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
361        Ok(serde_json::from_str(json.as_ref())?)
362    }
363    pub fn builder() -> ChatReportReasonPornographyBuilder {
364        let mut inner = ChatReportReasonPornography::default();
365        inner.extra = Some(Uuid::new_v4().to_string());
366
367        ChatReportReasonPornographyBuilder { inner }
368    }
369}
370
371#[doc(hidden)]
372pub struct ChatReportReasonPornographyBuilder {
373    inner: ChatReportReasonPornography,
374}
375
376#[deprecated]
377pub type RTDChatReportReasonPornographyBuilder = ChatReportReasonPornographyBuilder;
378
379impl ChatReportReasonPornographyBuilder {
380    pub fn build(&self) -> ChatReportReasonPornography {
381        self.inner.clone()
382    }
383}
384
385impl AsRef<ChatReportReasonPornography> for ChatReportReasonPornography {
386    fn as_ref(&self) -> &ChatReportReasonPornography {
387        self
388    }
389}
390
391impl AsRef<ChatReportReasonPornography> for ChatReportReasonPornographyBuilder {
392    fn as_ref(&self) -> &ChatReportReasonPornography {
393        &self.inner
394    }
395}
396
397/// The chat contains spam messages
398#[derive(Debug, Clone, Default, Serialize, Deserialize)]
399pub struct ChatReportReasonSpam {
400    #[doc(hidden)]
401    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
402    extra: Option<String>,
403    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
404    client_id: Option<i32>,
405}
406
407impl RObject for ChatReportReasonSpam {
408    #[doc(hidden)]
409    fn extra(&self) -> Option<&str> {
410        self.extra.as_deref()
411    }
412    #[doc(hidden)]
413    fn client_id(&self) -> Option<i32> {
414        self.client_id
415    }
416}
417
418impl TDChatReportReason for ChatReportReasonSpam {}
419
420impl ChatReportReasonSpam {
421    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
422        Ok(serde_json::from_str(json.as_ref())?)
423    }
424    pub fn builder() -> ChatReportReasonSpamBuilder {
425        let mut inner = ChatReportReasonSpam::default();
426        inner.extra = Some(Uuid::new_v4().to_string());
427
428        ChatReportReasonSpamBuilder { inner }
429    }
430}
431
432#[doc(hidden)]
433pub struct ChatReportReasonSpamBuilder {
434    inner: ChatReportReasonSpam,
435}
436
437#[deprecated]
438pub type RTDChatReportReasonSpamBuilder = ChatReportReasonSpamBuilder;
439
440impl ChatReportReasonSpamBuilder {
441    pub fn build(&self) -> ChatReportReasonSpam {
442        self.inner.clone()
443    }
444}
445
446impl AsRef<ChatReportReasonSpam> for ChatReportReasonSpam {
447    fn as_ref(&self) -> &ChatReportReasonSpam {
448        self
449    }
450}
451
452impl AsRef<ChatReportReasonSpam> for ChatReportReasonSpamBuilder {
453    fn as_ref(&self) -> &ChatReportReasonSpam {
454        &self.inner
455    }
456}
457
458/// The location-based chat is unrelated to its stated location
459#[derive(Debug, Clone, Default, Serialize, Deserialize)]
460pub struct ChatReportReasonUnrelatedLocation {
461    #[doc(hidden)]
462    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
463    extra: Option<String>,
464    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
465    client_id: Option<i32>,
466}
467
468impl RObject for ChatReportReasonUnrelatedLocation {
469    #[doc(hidden)]
470    fn extra(&self) -> Option<&str> {
471        self.extra.as_deref()
472    }
473    #[doc(hidden)]
474    fn client_id(&self) -> Option<i32> {
475        self.client_id
476    }
477}
478
479impl TDChatReportReason for ChatReportReasonUnrelatedLocation {}
480
481impl ChatReportReasonUnrelatedLocation {
482    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
483        Ok(serde_json::from_str(json.as_ref())?)
484    }
485    pub fn builder() -> ChatReportReasonUnrelatedLocationBuilder {
486        let mut inner = ChatReportReasonUnrelatedLocation::default();
487        inner.extra = Some(Uuid::new_v4().to_string());
488
489        ChatReportReasonUnrelatedLocationBuilder { inner }
490    }
491}
492
493#[doc(hidden)]
494pub struct ChatReportReasonUnrelatedLocationBuilder {
495    inner: ChatReportReasonUnrelatedLocation,
496}
497
498#[deprecated]
499pub type RTDChatReportReasonUnrelatedLocationBuilder = ChatReportReasonUnrelatedLocationBuilder;
500
501impl ChatReportReasonUnrelatedLocationBuilder {
502    pub fn build(&self) -> ChatReportReasonUnrelatedLocation {
503        self.inner.clone()
504    }
505}
506
507impl AsRef<ChatReportReasonUnrelatedLocation> for ChatReportReasonUnrelatedLocation {
508    fn as_ref(&self) -> &ChatReportReasonUnrelatedLocation {
509        self
510    }
511}
512
513impl AsRef<ChatReportReasonUnrelatedLocation> for ChatReportReasonUnrelatedLocationBuilder {
514    fn as_ref(&self) -> &ChatReportReasonUnrelatedLocation {
515        &self.inner
516    }
517}
518
519/// The chat promotes violence
520#[derive(Debug, Clone, Default, Serialize, Deserialize)]
521pub struct ChatReportReasonViolence {
522    #[doc(hidden)]
523    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
524    extra: Option<String>,
525    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
526    client_id: Option<i32>,
527}
528
529impl RObject for ChatReportReasonViolence {
530    #[doc(hidden)]
531    fn extra(&self) -> Option<&str> {
532        self.extra.as_deref()
533    }
534    #[doc(hidden)]
535    fn client_id(&self) -> Option<i32> {
536        self.client_id
537    }
538}
539
540impl TDChatReportReason for ChatReportReasonViolence {}
541
542impl ChatReportReasonViolence {
543    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
544        Ok(serde_json::from_str(json.as_ref())?)
545    }
546    pub fn builder() -> ChatReportReasonViolenceBuilder {
547        let mut inner = ChatReportReasonViolence::default();
548        inner.extra = Some(Uuid::new_v4().to_string());
549
550        ChatReportReasonViolenceBuilder { inner }
551    }
552}
553
554#[doc(hidden)]
555pub struct ChatReportReasonViolenceBuilder {
556    inner: ChatReportReasonViolence,
557}
558
559#[deprecated]
560pub type RTDChatReportReasonViolenceBuilder = ChatReportReasonViolenceBuilder;
561
562impl ChatReportReasonViolenceBuilder {
563    pub fn build(&self) -> ChatReportReasonViolence {
564        self.inner.clone()
565    }
566}
567
568impl AsRef<ChatReportReasonViolence> for ChatReportReasonViolence {
569    fn as_ref(&self) -> &ChatReportReasonViolence {
570        self
571    }
572}
573
574impl AsRef<ChatReportReasonViolence> for ChatReportReasonViolenceBuilder {
575    fn as_ref(&self) -> &ChatReportReasonViolence {
576        &self.inner
577    }
578}