Skip to main content

telers/types/
response_parameters.rs

1use serde::{Deserialize, Serialize};
2/// Describes why a request was unsuccessful.
3/// # Documentation
4/// <https://core.telegram.org/bots/api#responseparameters>
5#[derive(Clone, Debug, Serialize, Deserialize)]
6pub struct ResponseParameters {
7    /// The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub migrate_to_chat_id: Option<i64>,
10    /// In case of exceeding flood control, the number of seconds left to wait before the request can be repeated
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub retry_after: Option<i64>,
13}
14impl ResponseParameters {
15    /// Creates a new `ResponseParameters`.
16    ///
17    /// # Notes
18    /// Use builder methods to set optional fields.
19    #[must_use]
20    pub fn new() -> Self {
21        Self {
22            migrate_to_chat_id: None,
23            retry_after: None,
24        }
25    }
26
27    /// The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
28    #[must_use]
29    pub fn migrate_to_chat_id<T: Into<i64>>(self, val: T) -> Self {
30        let mut this = self;
31        this.migrate_to_chat_id = Some(val.into());
32        this
33    }
34
35    /// The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
36    #[must_use]
37    pub fn migrate_to_chat_id_option<T: Into<i64>>(self, val: Option<T>) -> Self {
38        let mut this = self;
39        this.migrate_to_chat_id = val.map(Into::into);
40        this
41    }
42
43    /// In case of exceeding flood control, the number of seconds left to wait before the request can be repeated
44    #[must_use]
45    pub fn retry_after<T: Into<i64>>(self, val: T) -> Self {
46        let mut this = self;
47        this.retry_after = Some(val.into());
48        this
49    }
50
51    /// In case of exceeding flood control, the number of seconds left to wait before the request can be repeated
52    #[must_use]
53    pub fn retry_after_option<T: Into<i64>>(self, val: Option<T>) -> Self {
54        let mut this = self;
55        this.retry_after = val.map(Into::into);
56        this
57    }
58}
59impl Default for ResponseParameters {
60    fn default() -> Self {
61        Self::new()
62    }
63}