rtdlib/types/
message_interaction_info.rs

1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9/// Contains information about interactions with a message
10#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct MessageInteractionInfo {
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  /// Number of times the message was viewed
19  view_count: i64,
20  /// Number of times the message was forwarded
21  forward_count: i64,
22  /// Information about direct or indirect replies to the message; may be null. Currently, available only in channels with a discussion supergroup and discussion supergroups for messages, which are not replies itself
23  reply_info: Option<MessageReplyInfo>,
24  
25}
26
27impl RObject for MessageInteractionInfo {
28  #[doc(hidden)] fn td_name(&self) -> &'static str { "messageInteractionInfo" }
29  #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
30  fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
31}
32
33
34
35impl MessageInteractionInfo {
36  pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
37  pub fn builder() -> RTDMessageInteractionInfoBuilder {
38    let mut inner = MessageInteractionInfo::default();
39    inner.td_name = "messageInteractionInfo".to_string();
40    inner.extra = Some(Uuid::new_v4().to_string());
41    RTDMessageInteractionInfoBuilder { inner }
42  }
43
44  pub fn view_count(&self) -> i64 { self.view_count }
45
46  pub fn forward_count(&self) -> i64 { self.forward_count }
47
48  pub fn reply_info(&self) -> &Option<MessageReplyInfo> { &self.reply_info }
49
50}
51
52#[doc(hidden)]
53pub struct RTDMessageInteractionInfoBuilder {
54  inner: MessageInteractionInfo
55}
56
57impl RTDMessageInteractionInfoBuilder {
58  pub fn build(&self) -> MessageInteractionInfo { self.inner.clone() }
59
60   
61  pub fn view_count(&mut self, view_count: i64) -> &mut Self {
62    self.inner.view_count = view_count;
63    self
64  }
65
66   
67  pub fn forward_count(&mut self, forward_count: i64) -> &mut Self {
68    self.inner.forward_count = forward_count;
69    self
70  }
71
72   
73  pub fn reply_info<T: AsRef<MessageReplyInfo>>(&mut self, reply_info: T) -> &mut Self {
74    self.inner.reply_info = Some(reply_info.as_ref().clone());
75    self
76  }
77
78}
79
80impl AsRef<MessageInteractionInfo> for MessageInteractionInfo {
81  fn as_ref(&self) -> &MessageInteractionInfo { self }
82}
83
84impl AsRef<MessageInteractionInfo> for RTDMessageInteractionInfoBuilder {
85  fn as_ref(&self) -> &MessageInteractionInfo { &self.inner }
86}
87
88
89