rust_tdlib/types/
toggle_chat_is_pinned.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct ToggleChatIsPinned {
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(skip_serializing_if = "ChatList::_is_default")]
16 chat_list: ChatList,
17 #[serde(default)]
20 chat_id: i64,
21 #[serde(default)]
24 is_pinned: bool,
25
26 #[serde(rename(serialize = "@type"))]
27 td_type: String,
28}
29
30impl RObject for ToggleChatIsPinned {
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 ToggleChatIsPinned {}
42
43impl ToggleChatIsPinned {
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() -> ToggleChatIsPinnedBuilder {
48 let mut inner = ToggleChatIsPinned::default();
49 inner.extra = Some(Uuid::new_v4().to_string());
50
51 inner.td_type = "toggleChatIsPinned".to_string();
52
53 ToggleChatIsPinnedBuilder { inner }
54 }
55
56 pub fn chat_list(&self) -> &ChatList {
57 &self.chat_list
58 }
59
60 pub fn chat_id(&self) -> i64 {
61 self.chat_id
62 }
63
64 pub fn is_pinned(&self) -> bool {
65 self.is_pinned
66 }
67}
68
69#[doc(hidden)]
70pub struct ToggleChatIsPinnedBuilder {
71 inner: ToggleChatIsPinned,
72}
73
74#[deprecated]
75pub type RTDToggleChatIsPinnedBuilder = ToggleChatIsPinnedBuilder;
76
77impl ToggleChatIsPinnedBuilder {
78 pub fn build(&self) -> ToggleChatIsPinned {
79 self.inner.clone()
80 }
81
82 pub fn chat_list<T: AsRef<ChatList>>(&mut self, chat_list: T) -> &mut Self {
83 self.inner.chat_list = chat_list.as_ref().clone();
84 self
85 }
86
87 pub fn chat_id(&mut self, chat_id: i64) -> &mut Self {
88 self.inner.chat_id = chat_id;
89 self
90 }
91
92 pub fn is_pinned(&mut self, is_pinned: bool) -> &mut Self {
93 self.inner.is_pinned = is_pinned;
94 self
95 }
96}
97
98impl AsRef<ToggleChatIsPinned> for ToggleChatIsPinned {
99 fn as_ref(&self) -> &ToggleChatIsPinned {
100 self
101 }
102}
103
104impl AsRef<ToggleChatIsPinned> for ToggleChatIsPinnedBuilder {
105 fn as_ref(&self) -> &ToggleChatIsPinned {
106 &self.inner
107 }
108}