rust_tdlib/types/
chat_invite_link_info.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Contains information about a chat invite link
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct ChatInviteLinkInfo {
8    #[doc(hidden)]
9    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
10    extra: Option<String>,
11    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
12    client_id: Option<i32>,
13    /// Chat identifier of the invite link; 0 if the user has no access to the chat before joining
14
15    #[serde(default)]
16    chat_id: i64,
17    /// If non-zero, the amount of time for which read access to the chat will remain available, in seconds
18
19    #[serde(default)]
20    accessible_for: i32,
21    /// Type of the chat
22
23    #[serde(rename(serialize = "type", deserialize = "type"))]
24    #[serde(skip_serializing_if = "ChatType::_is_default")]
25    type_: ChatType,
26    /// Title of the chat
27
28    #[serde(default)]
29    title: String,
30    /// Chat photo; may be null
31    photo: Option<ChatPhotoInfo>,
32    /// Contains information about a chat invite link
33
34    #[serde(default)]
35    description: String,
36    /// Number of members in the chat
37
38    #[serde(default)]
39    member_count: i32,
40    /// User identifiers of some chat members that may be known to the current user
41
42    #[serde(default)]
43    member_user_ids: Vec<i64>,
44    /// True, if the link only creates join request
45
46    #[serde(default)]
47    creates_join_request: bool,
48    /// True, if the chat is a public supergroup or channel, i.e. it has a username or it is a location-based supergroup
49
50    #[serde(default)]
51    is_public: bool,
52}
53
54impl RObject for ChatInviteLinkInfo {
55    #[doc(hidden)]
56    fn extra(&self) -> Option<&str> {
57        self.extra.as_deref()
58    }
59    #[doc(hidden)]
60    fn client_id(&self) -> Option<i32> {
61        self.client_id
62    }
63}
64
65impl ChatInviteLinkInfo {
66    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
67        Ok(serde_json::from_str(json.as_ref())?)
68    }
69    pub fn builder() -> ChatInviteLinkInfoBuilder {
70        let mut inner = ChatInviteLinkInfo::default();
71        inner.extra = Some(Uuid::new_v4().to_string());
72
73        ChatInviteLinkInfoBuilder { inner }
74    }
75
76    pub fn chat_id(&self) -> i64 {
77        self.chat_id
78    }
79
80    pub fn accessible_for(&self) -> i32 {
81        self.accessible_for
82    }
83
84    pub fn type_(&self) -> &ChatType {
85        &self.type_
86    }
87
88    pub fn title(&self) -> &String {
89        &self.title
90    }
91
92    pub fn photo(&self) -> &Option<ChatPhotoInfo> {
93        &self.photo
94    }
95
96    pub fn description(&self) -> &String {
97        &self.description
98    }
99
100    pub fn member_count(&self) -> i32 {
101        self.member_count
102    }
103
104    pub fn member_user_ids(&self) -> &Vec<i64> {
105        &self.member_user_ids
106    }
107
108    pub fn creates_join_request(&self) -> bool {
109        self.creates_join_request
110    }
111
112    pub fn is_public(&self) -> bool {
113        self.is_public
114    }
115}
116
117#[doc(hidden)]
118pub struct ChatInviteLinkInfoBuilder {
119    inner: ChatInviteLinkInfo,
120}
121
122#[deprecated]
123pub type RTDChatInviteLinkInfoBuilder = ChatInviteLinkInfoBuilder;
124
125impl ChatInviteLinkInfoBuilder {
126    pub fn build(&self) -> ChatInviteLinkInfo {
127        self.inner.clone()
128    }
129
130    pub fn chat_id(&mut self, chat_id: i64) -> &mut Self {
131        self.inner.chat_id = chat_id;
132        self
133    }
134
135    pub fn accessible_for(&mut self, accessible_for: i32) -> &mut Self {
136        self.inner.accessible_for = accessible_for;
137        self
138    }
139
140    pub fn type_<T: AsRef<ChatType>>(&mut self, type_: T) -> &mut Self {
141        self.inner.type_ = type_.as_ref().clone();
142        self
143    }
144
145    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
146        self.inner.title = title.as_ref().to_string();
147        self
148    }
149
150    pub fn photo<T: AsRef<ChatPhotoInfo>>(&mut self, photo: T) -> &mut Self {
151        self.inner.photo = Some(photo.as_ref().clone());
152        self
153    }
154
155    pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
156        self.inner.description = description.as_ref().to_string();
157        self
158    }
159
160    pub fn member_count(&mut self, member_count: i32) -> &mut Self {
161        self.inner.member_count = member_count;
162        self
163    }
164
165    pub fn member_user_ids(&mut self, member_user_ids: Vec<i64>) -> &mut Self {
166        self.inner.member_user_ids = member_user_ids;
167        self
168    }
169
170    pub fn creates_join_request(&mut self, creates_join_request: bool) -> &mut Self {
171        self.inner.creates_join_request = creates_join_request;
172        self
173    }
174
175    pub fn is_public(&mut self, is_public: bool) -> &mut Self {
176        self.inner.is_public = is_public;
177        self
178    }
179}
180
181impl AsRef<ChatInviteLinkInfo> for ChatInviteLinkInfo {
182    fn as_ref(&self) -> &ChatInviteLinkInfo {
183        self
184    }
185}
186
187impl AsRef<ChatInviteLinkInfo> for ChatInviteLinkInfoBuilder {
188    fn as_ref(&self) -> &ChatInviteLinkInfo {
189        &self.inner
190    }
191}