rust_tdlib/types/
get_group_call_stream_segment.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Returns a file with a segment of a group call stream in a modified OGG format for audio or MPEG-4 format for video
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct GetGroupCallStreamSegment {
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    /// Group call identifier
14
15    #[serde(default)]
16    group_call_id: i32,
17    /// Point in time when the stream segment begins; Unix timestamp in milliseconds
18
19    #[serde(default)]
20    time_offset: i64,
21    /// Segment duration scale; 0-1. Segment's duration is 1000/(2**scale) milliseconds
22
23    #[serde(default)]
24    scale: i32,
25    /// Identifier of an audio/video channel to get as received from tgcalls
26
27    #[serde(default)]
28    channel_id: i32,
29    /// Video quality as received from tgcalls; pass null to get the worst available quality
30
31    #[serde(skip_serializing_if = "GroupCallVideoQuality::_is_default")]
32    video_quality: GroupCallVideoQuality,
33
34    #[serde(rename(serialize = "@type"))]
35    td_type: String,
36}
37
38impl RObject for GetGroupCallStreamSegment {
39    #[doc(hidden)]
40    fn extra(&self) -> Option<&str> {
41        self.extra.as_deref()
42    }
43    #[doc(hidden)]
44    fn client_id(&self) -> Option<i32> {
45        self.client_id
46    }
47}
48
49impl RFunction for GetGroupCallStreamSegment {}
50
51impl GetGroupCallStreamSegment {
52    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
53        Ok(serde_json::from_str(json.as_ref())?)
54    }
55    pub fn builder() -> GetGroupCallStreamSegmentBuilder {
56        let mut inner = GetGroupCallStreamSegment::default();
57        inner.extra = Some(Uuid::new_v4().to_string());
58
59        inner.td_type = "getGroupCallStreamSegment".to_string();
60
61        GetGroupCallStreamSegmentBuilder { inner }
62    }
63
64    pub fn group_call_id(&self) -> i32 {
65        self.group_call_id
66    }
67
68    pub fn time_offset(&self) -> i64 {
69        self.time_offset
70    }
71
72    pub fn scale(&self) -> i32 {
73        self.scale
74    }
75
76    pub fn channel_id(&self) -> i32 {
77        self.channel_id
78    }
79
80    pub fn video_quality(&self) -> &GroupCallVideoQuality {
81        &self.video_quality
82    }
83}
84
85#[doc(hidden)]
86pub struct GetGroupCallStreamSegmentBuilder {
87    inner: GetGroupCallStreamSegment,
88}
89
90#[deprecated]
91pub type RTDGetGroupCallStreamSegmentBuilder = GetGroupCallStreamSegmentBuilder;
92
93impl GetGroupCallStreamSegmentBuilder {
94    pub fn build(&self) -> GetGroupCallStreamSegment {
95        self.inner.clone()
96    }
97
98    pub fn group_call_id(&mut self, group_call_id: i32) -> &mut Self {
99        self.inner.group_call_id = group_call_id;
100        self
101    }
102
103    pub fn time_offset(&mut self, time_offset: i64) -> &mut Self {
104        self.inner.time_offset = time_offset;
105        self
106    }
107
108    pub fn scale(&mut self, scale: i32) -> &mut Self {
109        self.inner.scale = scale;
110        self
111    }
112
113    pub fn channel_id(&mut self, channel_id: i32) -> &mut Self {
114        self.inner.channel_id = channel_id;
115        self
116    }
117
118    pub fn video_quality<T: AsRef<GroupCallVideoQuality>>(
119        &mut self,
120        video_quality: T,
121    ) -> &mut Self {
122        self.inner.video_quality = video_quality.as_ref().clone();
123        self
124    }
125}
126
127impl AsRef<GetGroupCallStreamSegment> for GetGroupCallStreamSegment {
128    fn as_ref(&self) -> &GetGroupCallStreamSegment {
129        self
130    }
131}
132
133impl AsRef<GetGroupCallStreamSegment> for GetGroupCallStreamSegmentBuilder {
134    fn as_ref(&self) -> &GetGroupCallStreamSegment {
135        &self.inner
136    }
137}