rust_tdlib/types/
group_call.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct GroupCall {
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 #[serde(default)]
16 id: i32,
17 #[serde(default)]
20 title: String,
21 #[serde(default)]
24 scheduled_start_date: i32,
25 #[serde(default)]
28 enabled_start_notification: bool,
29 #[serde(default)]
32 is_active: bool,
33 #[serde(default)]
36 is_joined: bool,
37 #[serde(default)]
40 need_rejoin: bool,
41 #[serde(default)]
44 can_be_managed: bool,
45 #[serde(default)]
48 participant_count: i32,
49 #[serde(default)]
52 loaded_all_participants: bool,
53 #[serde(default)]
56 recent_speakers: Vec<GroupCallRecentSpeaker>,
57 #[serde(default)]
60 is_my_video_enabled: bool,
61 #[serde(default)]
64 is_my_video_paused: bool,
65 #[serde(default)]
68 can_enable_video: bool,
69 #[serde(default)]
72 mute_new_participants: bool,
73 #[serde(default)]
76 can_toggle_mute_new_participants: bool,
77 #[serde(default)]
80 record_duration: i32,
81 #[serde(default)]
84 is_video_recorded: bool,
85 #[serde(default)]
88 duration: i32,
89}
90
91impl RObject for GroupCall {
92 #[doc(hidden)]
93 fn extra(&self) -> Option<&str> {
94 self.extra.as_deref()
95 }
96 #[doc(hidden)]
97 fn client_id(&self) -> Option<i32> {
98 self.client_id
99 }
100}
101
102impl GroupCall {
103 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
104 Ok(serde_json::from_str(json.as_ref())?)
105 }
106 pub fn builder() -> GroupCallBuilder {
107 let mut inner = GroupCall::default();
108 inner.extra = Some(Uuid::new_v4().to_string());
109
110 GroupCallBuilder { inner }
111 }
112
113 pub fn id(&self) -> i32 {
114 self.id
115 }
116
117 pub fn title(&self) -> &String {
118 &self.title
119 }
120
121 pub fn scheduled_start_date(&self) -> i32 {
122 self.scheduled_start_date
123 }
124
125 pub fn enabled_start_notification(&self) -> bool {
126 self.enabled_start_notification
127 }
128
129 pub fn is_active(&self) -> bool {
130 self.is_active
131 }
132
133 pub fn is_joined(&self) -> bool {
134 self.is_joined
135 }
136
137 pub fn need_rejoin(&self) -> bool {
138 self.need_rejoin
139 }
140
141 pub fn can_be_managed(&self) -> bool {
142 self.can_be_managed
143 }
144
145 pub fn participant_count(&self) -> i32 {
146 self.participant_count
147 }
148
149 pub fn loaded_all_participants(&self) -> bool {
150 self.loaded_all_participants
151 }
152
153 pub fn recent_speakers(&self) -> &Vec<GroupCallRecentSpeaker> {
154 &self.recent_speakers
155 }
156
157 pub fn is_my_video_enabled(&self) -> bool {
158 self.is_my_video_enabled
159 }
160
161 pub fn is_my_video_paused(&self) -> bool {
162 self.is_my_video_paused
163 }
164
165 pub fn can_enable_video(&self) -> bool {
166 self.can_enable_video
167 }
168
169 pub fn mute_new_participants(&self) -> bool {
170 self.mute_new_participants
171 }
172
173 pub fn can_toggle_mute_new_participants(&self) -> bool {
174 self.can_toggle_mute_new_participants
175 }
176
177 pub fn record_duration(&self) -> i32 {
178 self.record_duration
179 }
180
181 pub fn is_video_recorded(&self) -> bool {
182 self.is_video_recorded
183 }
184
185 pub fn duration(&self) -> i32 {
186 self.duration
187 }
188}
189
190#[doc(hidden)]
191pub struct GroupCallBuilder {
192 inner: GroupCall,
193}
194
195#[deprecated]
196pub type RTDGroupCallBuilder = GroupCallBuilder;
197
198impl GroupCallBuilder {
199 pub fn build(&self) -> GroupCall {
200 self.inner.clone()
201 }
202
203 pub fn id(&mut self, id: i32) -> &mut Self {
204 self.inner.id = id;
205 self
206 }
207
208 pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
209 self.inner.title = title.as_ref().to_string();
210 self
211 }
212
213 pub fn scheduled_start_date(&mut self, scheduled_start_date: i32) -> &mut Self {
214 self.inner.scheduled_start_date = scheduled_start_date;
215 self
216 }
217
218 pub fn enabled_start_notification(&mut self, enabled_start_notification: bool) -> &mut Self {
219 self.inner.enabled_start_notification = enabled_start_notification;
220 self
221 }
222
223 pub fn is_active(&mut self, is_active: bool) -> &mut Self {
224 self.inner.is_active = is_active;
225 self
226 }
227
228 pub fn is_joined(&mut self, is_joined: bool) -> &mut Self {
229 self.inner.is_joined = is_joined;
230 self
231 }
232
233 pub fn need_rejoin(&mut self, need_rejoin: bool) -> &mut Self {
234 self.inner.need_rejoin = need_rejoin;
235 self
236 }
237
238 pub fn can_be_managed(&mut self, can_be_managed: bool) -> &mut Self {
239 self.inner.can_be_managed = can_be_managed;
240 self
241 }
242
243 pub fn participant_count(&mut self, participant_count: i32) -> &mut Self {
244 self.inner.participant_count = participant_count;
245 self
246 }
247
248 pub fn loaded_all_participants(&mut self, loaded_all_participants: bool) -> &mut Self {
249 self.inner.loaded_all_participants = loaded_all_participants;
250 self
251 }
252
253 pub fn recent_speakers(&mut self, recent_speakers: Vec<GroupCallRecentSpeaker>) -> &mut Self {
254 self.inner.recent_speakers = recent_speakers;
255 self
256 }
257
258 pub fn is_my_video_enabled(&mut self, is_my_video_enabled: bool) -> &mut Self {
259 self.inner.is_my_video_enabled = is_my_video_enabled;
260 self
261 }
262
263 pub fn is_my_video_paused(&mut self, is_my_video_paused: bool) -> &mut Self {
264 self.inner.is_my_video_paused = is_my_video_paused;
265 self
266 }
267
268 pub fn can_enable_video(&mut self, can_enable_video: bool) -> &mut Self {
269 self.inner.can_enable_video = can_enable_video;
270 self
271 }
272
273 pub fn mute_new_participants(&mut self, mute_new_participants: bool) -> &mut Self {
274 self.inner.mute_new_participants = mute_new_participants;
275 self
276 }
277
278 pub fn can_toggle_mute_new_participants(
279 &mut self,
280 can_toggle_mute_new_participants: bool,
281 ) -> &mut Self {
282 self.inner.can_toggle_mute_new_participants = can_toggle_mute_new_participants;
283 self
284 }
285
286 pub fn record_duration(&mut self, record_duration: i32) -> &mut Self {
287 self.inner.record_duration = record_duration;
288 self
289 }
290
291 pub fn is_video_recorded(&mut self, is_video_recorded: bool) -> &mut Self {
292 self.inner.is_video_recorded = is_video_recorded;
293 self
294 }
295
296 pub fn duration(&mut self, duration: i32) -> &mut Self {
297 self.inner.duration = duration;
298 self
299 }
300}
301
302impl AsRef<GroupCall> for GroupCall {
303 fn as_ref(&self) -> &GroupCall {
304 self
305 }
306}
307
308impl AsRef<GroupCall> for GroupCallBuilder {
309 fn as_ref(&self) -> &GroupCall {
310 &self.inner
311 }
312}