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