rust_tdlib/types/
accept_call.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct AcceptCall {
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 call_id: i32,
17 protocol: CallProtocol,
19
20 #[serde(rename(serialize = "@type"))]
21 td_type: String,
22}
23
24impl RObject for AcceptCall {
25 #[doc(hidden)]
26 fn extra(&self) -> Option<&str> {
27 self.extra.as_deref()
28 }
29 #[doc(hidden)]
30 fn client_id(&self) -> Option<i32> {
31 self.client_id
32 }
33}
34
35impl RFunction for AcceptCall {}
36
37impl AcceptCall {
38 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
39 Ok(serde_json::from_str(json.as_ref())?)
40 }
41 pub fn builder() -> AcceptCallBuilder {
42 let mut inner = AcceptCall::default();
43 inner.extra = Some(Uuid::new_v4().to_string());
44
45 inner.td_type = "acceptCall".to_string();
46
47 AcceptCallBuilder { inner }
48 }
49
50 pub fn call_id(&self) -> i32 {
51 self.call_id
52 }
53
54 pub fn protocol(&self) -> &CallProtocol {
55 &self.protocol
56 }
57}
58
59#[doc(hidden)]
60pub struct AcceptCallBuilder {
61 inner: AcceptCall,
62}
63
64#[deprecated]
65pub type RTDAcceptCallBuilder = AcceptCallBuilder;
66
67impl AcceptCallBuilder {
68 pub fn build(&self) -> AcceptCall {
69 self.inner.clone()
70 }
71
72 pub fn call_id(&mut self, call_id: i32) -> &mut Self {
73 self.inner.call_id = call_id;
74 self
75 }
76
77 pub fn protocol<T: AsRef<CallProtocol>>(&mut self, protocol: T) -> &mut Self {
78 self.inner.protocol = protocol.as_ref().clone();
79 self
80 }
81}
82
83impl AsRef<AcceptCall> for AcceptCall {
84 fn as_ref(&self) -> &AcceptCall {
85 self
86 }
87}
88
89impl AsRef<AcceptCall> for AcceptCallBuilder {
90 fn as_ref(&self) -> &AcceptCall {
91 &self.inner
92 }
93}