rust_tdlib/types/
group_call_participant.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Represents a group call participant
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct GroupCallParticipant {
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    /// Identifier of the group call participant
14
15    #[serde(skip_serializing_if = "MessageSender::_is_default")]
16    participant_id: MessageSender,
17    /// User's audio channel synchronization source identifier
18
19    #[serde(default)]
20    audio_source_id: i32,
21    /// User's screen sharing audio channel synchronization source identifier
22
23    #[serde(default)]
24    screen_sharing_audio_source_id: i32,
25    /// Information about user's video channel; may be null if there is no active video
26    video_info: Option<GroupCallParticipantVideoInfo>,
27    /// Information about user's screen sharing video channel; may be null if there is no active screen sharing video
28    screen_sharing_video_info: Option<GroupCallParticipantVideoInfo>,
29    /// The participant user's bio or the participant chat's description
30
31    #[serde(default)]
32    bio: String,
33    /// True, if the participant is the current user
34
35    #[serde(default)]
36    is_current_user: bool,
37    /// True, if the participant is speaking as set by setGroupCallParticipantIsSpeaking
38
39    #[serde(default)]
40    is_speaking: bool,
41    /// True, if the participant hand is raised
42
43    #[serde(default)]
44    is_hand_raised: bool,
45    /// True, if the current user can mute the participant for all other group call participants
46
47    #[serde(default)]
48    can_be_muted_for_all_users: bool,
49    /// True, if the current user can allow the participant to unmute themselves or unmute the participant (if the participant is the current user)
50
51    #[serde(default)]
52    can_be_unmuted_for_all_users: bool,
53    /// True, if the current user can mute the participant only for self
54
55    #[serde(default)]
56    can_be_muted_for_current_user: bool,
57    /// True, if the current user can unmute the participant for self
58
59    #[serde(default)]
60    can_be_unmuted_for_current_user: bool,
61    /// True, if the participant is muted for all users
62
63    #[serde(default)]
64    is_muted_for_all_users: bool,
65    /// True, if the participant is muted for the current user
66
67    #[serde(default)]
68    is_muted_for_current_user: bool,
69    /// True, if the participant is muted for all users, but can unmute themselves
70
71    #[serde(default)]
72    can_unmute_self: bool,
73    /// Participant's volume level; 1-20000 in hundreds of percents
74
75    #[serde(default)]
76    volume_level: i32,
77    /// User's order in the group call participant list. Orders must be compared lexicographically. The bigger is order, the higher is user in the list. If order is empty, the user must be removed from the participant list
78
79    #[serde(default)]
80    order: String,
81}
82
83impl RObject for GroupCallParticipant {
84    #[doc(hidden)]
85    fn extra(&self) -> Option<&str> {
86        self.extra.as_deref()
87    }
88    #[doc(hidden)]
89    fn client_id(&self) -> Option<i32> {
90        self.client_id
91    }
92}
93
94impl GroupCallParticipant {
95    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
96        Ok(serde_json::from_str(json.as_ref())?)
97    }
98    pub fn builder() -> GroupCallParticipantBuilder {
99        let mut inner = GroupCallParticipant::default();
100        inner.extra = Some(Uuid::new_v4().to_string());
101
102        GroupCallParticipantBuilder { inner }
103    }
104
105    pub fn participant_id(&self) -> &MessageSender {
106        &self.participant_id
107    }
108
109    pub fn audio_source_id(&self) -> i32 {
110        self.audio_source_id
111    }
112
113    pub fn screen_sharing_audio_source_id(&self) -> i32 {
114        self.screen_sharing_audio_source_id
115    }
116
117    pub fn video_info(&self) -> &Option<GroupCallParticipantVideoInfo> {
118        &self.video_info
119    }
120
121    pub fn screen_sharing_video_info(&self) -> &Option<GroupCallParticipantVideoInfo> {
122        &self.screen_sharing_video_info
123    }
124
125    pub fn bio(&self) -> &String {
126        &self.bio
127    }
128
129    pub fn is_current_user(&self) -> bool {
130        self.is_current_user
131    }
132
133    pub fn is_speaking(&self) -> bool {
134        self.is_speaking
135    }
136
137    pub fn is_hand_raised(&self) -> bool {
138        self.is_hand_raised
139    }
140
141    pub fn can_be_muted_for_all_users(&self) -> bool {
142        self.can_be_muted_for_all_users
143    }
144
145    pub fn can_be_unmuted_for_all_users(&self) -> bool {
146        self.can_be_unmuted_for_all_users
147    }
148
149    pub fn can_be_muted_for_current_user(&self) -> bool {
150        self.can_be_muted_for_current_user
151    }
152
153    pub fn can_be_unmuted_for_current_user(&self) -> bool {
154        self.can_be_unmuted_for_current_user
155    }
156
157    pub fn is_muted_for_all_users(&self) -> bool {
158        self.is_muted_for_all_users
159    }
160
161    pub fn is_muted_for_current_user(&self) -> bool {
162        self.is_muted_for_current_user
163    }
164
165    pub fn can_unmute_self(&self) -> bool {
166        self.can_unmute_self
167    }
168
169    pub fn volume_level(&self) -> i32 {
170        self.volume_level
171    }
172
173    pub fn order(&self) -> &String {
174        &self.order
175    }
176}
177
178#[doc(hidden)]
179pub struct GroupCallParticipantBuilder {
180    inner: GroupCallParticipant,
181}
182
183#[deprecated]
184pub type RTDGroupCallParticipantBuilder = GroupCallParticipantBuilder;
185
186impl GroupCallParticipantBuilder {
187    pub fn build(&self) -> GroupCallParticipant {
188        self.inner.clone()
189    }
190
191    pub fn participant_id<T: AsRef<MessageSender>>(&mut self, participant_id: T) -> &mut Self {
192        self.inner.participant_id = participant_id.as_ref().clone();
193        self
194    }
195
196    pub fn audio_source_id(&mut self, audio_source_id: i32) -> &mut Self {
197        self.inner.audio_source_id = audio_source_id;
198        self
199    }
200
201    pub fn screen_sharing_audio_source_id(
202        &mut self,
203        screen_sharing_audio_source_id: i32,
204    ) -> &mut Self {
205        self.inner.screen_sharing_audio_source_id = screen_sharing_audio_source_id;
206        self
207    }
208
209    pub fn video_info<T: AsRef<GroupCallParticipantVideoInfo>>(
210        &mut self,
211        video_info: T,
212    ) -> &mut Self {
213        self.inner.video_info = Some(video_info.as_ref().clone());
214        self
215    }
216
217    pub fn screen_sharing_video_info<T: AsRef<GroupCallParticipantVideoInfo>>(
218        &mut self,
219        screen_sharing_video_info: T,
220    ) -> &mut Self {
221        self.inner.screen_sharing_video_info = Some(screen_sharing_video_info.as_ref().clone());
222        self
223    }
224
225    pub fn bio<T: AsRef<str>>(&mut self, bio: T) -> &mut Self {
226        self.inner.bio = bio.as_ref().to_string();
227        self
228    }
229
230    pub fn is_current_user(&mut self, is_current_user: bool) -> &mut Self {
231        self.inner.is_current_user = is_current_user;
232        self
233    }
234
235    pub fn is_speaking(&mut self, is_speaking: bool) -> &mut Self {
236        self.inner.is_speaking = is_speaking;
237        self
238    }
239
240    pub fn is_hand_raised(&mut self, is_hand_raised: bool) -> &mut Self {
241        self.inner.is_hand_raised = is_hand_raised;
242        self
243    }
244
245    pub fn can_be_muted_for_all_users(&mut self, can_be_muted_for_all_users: bool) -> &mut Self {
246        self.inner.can_be_muted_for_all_users = can_be_muted_for_all_users;
247        self
248    }
249
250    pub fn can_be_unmuted_for_all_users(
251        &mut self,
252        can_be_unmuted_for_all_users: bool,
253    ) -> &mut Self {
254        self.inner.can_be_unmuted_for_all_users = can_be_unmuted_for_all_users;
255        self
256    }
257
258    pub fn can_be_muted_for_current_user(
259        &mut self,
260        can_be_muted_for_current_user: bool,
261    ) -> &mut Self {
262        self.inner.can_be_muted_for_current_user = can_be_muted_for_current_user;
263        self
264    }
265
266    pub fn can_be_unmuted_for_current_user(
267        &mut self,
268        can_be_unmuted_for_current_user: bool,
269    ) -> &mut Self {
270        self.inner.can_be_unmuted_for_current_user = can_be_unmuted_for_current_user;
271        self
272    }
273
274    pub fn is_muted_for_all_users(&mut self, is_muted_for_all_users: bool) -> &mut Self {
275        self.inner.is_muted_for_all_users = is_muted_for_all_users;
276        self
277    }
278
279    pub fn is_muted_for_current_user(&mut self, is_muted_for_current_user: bool) -> &mut Self {
280        self.inner.is_muted_for_current_user = is_muted_for_current_user;
281        self
282    }
283
284    pub fn can_unmute_self(&mut self, can_unmute_self: bool) -> &mut Self {
285        self.inner.can_unmute_self = can_unmute_self;
286        self
287    }
288
289    pub fn volume_level(&mut self, volume_level: i32) -> &mut Self {
290        self.inner.volume_level = volume_level;
291        self
292    }
293
294    pub fn order<T: AsRef<str>>(&mut self, order: T) -> &mut Self {
295        self.inner.order = order.as_ref().to_string();
296        self
297    }
298}
299
300impl AsRef<GroupCallParticipant> for GroupCallParticipant {
301    fn as_ref(&self) -> &GroupCallParticipant {
302        self
303    }
304}
305
306impl AsRef<GroupCallParticipant> for GroupCallParticipantBuilder {
307    fn as_ref(&self) -> &GroupCallParticipant {
308        &self.inner
309    }
310}