rtdlib/types/
chat_invite_links.rs1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct ChatInviteLinks {
12 #[doc(hidden)]
13 #[serde(rename(serialize = "@type", deserialize = "@type"))]
14 td_name: String,
15 #[doc(hidden)]
16 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17 extra: Option<String>,
18 total_count: i64,
20 invite_links: Vec<ChatInviteLink>,
22
23}
24
25impl RObject for ChatInviteLinks {
26 #[doc(hidden)] fn td_name(&self) -> &'static str { "chatInviteLinks" }
27 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
28 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
29}
30
31
32
33impl ChatInviteLinks {
34 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
35 pub fn builder() -> RTDChatInviteLinksBuilder {
36 let mut inner = ChatInviteLinks::default();
37 inner.td_name = "chatInviteLinks".to_string();
38 inner.extra = Some(Uuid::new_v4().to_string());
39 RTDChatInviteLinksBuilder { inner }
40 }
41
42 pub fn total_count(&self) -> i64 { self.total_count }
43
44 pub fn invite_links(&self) -> &Vec<ChatInviteLink> { &self.invite_links }
45
46}
47
48#[doc(hidden)]
49pub struct RTDChatInviteLinksBuilder {
50 inner: ChatInviteLinks
51}
52
53impl RTDChatInviteLinksBuilder {
54 pub fn build(&self) -> ChatInviteLinks { self.inner.clone() }
55
56
57 pub fn total_count(&mut self, total_count: i64) -> &mut Self {
58 self.inner.total_count = total_count;
59 self
60 }
61
62
63 pub fn invite_links(&mut self, invite_links: Vec<ChatInviteLink>) -> &mut Self {
64 self.inner.invite_links = invite_links;
65 self
66 }
67
68}
69
70impl AsRef<ChatInviteLinks> for ChatInviteLinks {
71 fn as_ref(&self) -> &ChatInviteLinks { self }
72}
73
74impl AsRef<ChatInviteLinks> for RTDChatInviteLinksBuilder {
75 fn as_ref(&self) -> &ChatInviteLinks { &self.inner }
76}
77
78
79