rtdlib/types/
message_forward_info.rs

1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9/// Contains information about a forwarded message
10#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct MessageForwardInfo {
12  #[doc(hidden)]
13  #[serde(rename(serialize = "@type", deserialize = "@type"))]
14  td_name: String,
15  #[doc(hidden)]
16  #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17  extra: Option<String>,
18  /// Origin of a forwarded message
19  origin: MessageForwardOrigin,
20  /// Point in time (Unix timestamp) when the message was originally sent
21  date: i64,
22  /// The type of a public service announcement for the forwarded message
23  public_service_announcement_type: String,
24  /// For messages forwarded to the chat with the current user (Saved Messages), to the Replies bot chat, or to the channel's discussion group, the identifier of the chat from which the message was forwarded last time; 0 if unknown
25  from_chat_id: i64,
26  /// For messages forwarded to the chat with the current user (Saved Messages), to the Replies bot chat, or to the channel's discussion group, the identifier of the original message from which the new message was forwarded last time; 0 if unknown
27  from_message_id: i64,
28  
29}
30
31impl RObject for MessageForwardInfo {
32  #[doc(hidden)] fn td_name(&self) -> &'static str { "messageForwardInfo" }
33  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
34  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
35}
36
37
38
39impl MessageForwardInfo {
40  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
41  pub fn builder() -> RTDMessageForwardInfoBuilder {
42    let mut inner = MessageForwardInfo::default();
43    inner.td_name = "messageForwardInfo".to_string();
44    inner.extra = Some(Uuid::new_v4().to_string());
45    RTDMessageForwardInfoBuilder { inner }
46  }
47
48  pub fn origin(&self) -> &MessageForwardOrigin { &self.origin }
49
50  pub fn date(&self) -> i64 { self.date }
51
52  pub fn public_service_announcement_type(&self) -> &String { &self.public_service_announcement_type }
53
54  pub fn from_chat_id(&self) -> i64 { self.from_chat_id }
55
56  pub fn from_message_id(&self) -> i64 { self.from_message_id }
57
58}
59
60#[doc(hidden)]
61pub struct RTDMessageForwardInfoBuilder {
62  inner: MessageForwardInfo
63}
64
65impl RTDMessageForwardInfoBuilder {
66  pub fn build(&self) -> MessageForwardInfo { self.inner.clone() }
67
68   
69  pub fn origin<T: AsRef<MessageForwardOrigin>>(&mut self, origin: T) -> &mut Self {
70    self.inner.origin = origin.as_ref().clone();
71    self
72  }
73
74   
75  pub fn date(&mut self, date: i64) -> &mut Self {
76    self.inner.date = date;
77    self
78  }
79
80   
81  pub fn public_service_announcement_type<T: AsRef<str>>(&mut self, public_service_announcement_type: T) -> &mut Self {
82    self.inner.public_service_announcement_type = public_service_announcement_type.as_ref().to_string();
83    self
84  }
85
86   
87  pub fn from_chat_id(&mut self, from_chat_id: i64) -> &mut Self {
88    self.inner.from_chat_id = from_chat_id;
89    self
90  }
91
92   
93  pub fn from_message_id(&mut self, from_message_id: i64) -> &mut Self {
94    self.inner.from_message_id = from_message_id;
95    self
96  }
97
98}
99
100impl AsRef<MessageForwardInfo> for MessageForwardInfo {
101  fn as_ref(&self) -> &MessageForwardInfo { self }
102}
103
104impl AsRef<MessageForwardInfo> for RTDMessageForwardInfoBuilder {
105  fn as_ref(&self) -> &MessageForwardInfo { &self.inner }
106}
107
108
109