rust_tdlib/types/
get_game_high_scores.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Returns the high scores for a game and some part of the high score table in the range of the specified user; for bots only
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct GetGameHighScores {
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    /// The chat that contains the message with the game
14
15    #[serde(default)]
16    chat_id: i64,
17    /// Identifier of the message
18
19    #[serde(default)]
20    message_id: i64,
21    /// User identifier
22
23    #[serde(default)]
24    user_id: i64,
25
26    #[serde(rename(serialize = "@type"))]
27    td_type: String,
28}
29
30impl RObject for GetGameHighScores {
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 GetGameHighScores {}
42
43impl GetGameHighScores {
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() -> GetGameHighScoresBuilder {
48        let mut inner = GetGameHighScores::default();
49        inner.extra = Some(Uuid::new_v4().to_string());
50
51        inner.td_type = "getGameHighScores".to_string();
52
53        GetGameHighScoresBuilder { 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 user_id(&self) -> i64 {
65        self.user_id
66    }
67}
68
69#[doc(hidden)]
70pub struct GetGameHighScoresBuilder {
71    inner: GetGameHighScores,
72}
73
74#[deprecated]
75pub type RTDGetGameHighScoresBuilder = GetGameHighScoresBuilder;
76
77impl GetGameHighScoresBuilder {
78    pub fn build(&self) -> GetGameHighScores {
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 user_id(&mut self, user_id: i64) -> &mut Self {
93        self.inner.user_id = user_id;
94        self
95    }
96}
97
98impl AsRef<GetGameHighScores> for GetGameHighScores {
99    fn as_ref(&self) -> &GetGameHighScores {
100        self
101    }
102}
103
104impl AsRef<GetGameHighScores> for GetGameHighScoresBuilder {
105    fn as_ref(&self) -> &GetGameHighScores {
106        &self.inner
107    }
108}