1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use serde::{Deserialize, Serialize};
/// This object contains information about a chat that was shared with the bot using a [`crate::types::KeyboardButtonRequestChat`] button.
/// # Documentation
/// <https://core.telegram.org/bots/api#chatshared>
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ChatShared {
/// Identifier of the request
pub request_id: i64,
/// Identifier of the shared chat. 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 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
pub chat_id: i64,
/// Title of the chat, if the title was requested by the bot.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<Box<str>>,
/// Username of the chat, if the username was requested by the bot and available.
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<Box<str>>,
/// Available sizes of the chat photo, if the photo was requested by the bot
#[serde(skip_serializing_if = "Option::is_none")]
pub photo: Option<Box<[crate::types::PhotoSize]>>,
}
impl ChatShared {
/// Creates a new `ChatShared`.
///
/// # Arguments
/// * `request_id` - Identifier of the request
/// * `chat_id` - Identifier of the shared chat. 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 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<i64>, T1: Into<i64>>(request_id: T0, chat_id: T1) -> Self {
Self {
request_id: request_id.into(),
chat_id: chat_id.into(),
title: None,
username: None,
photo: None,
}
}
/// Identifier of the request
#[must_use]
pub fn request_id<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.request_id = val.into();
this
}
/// Identifier of the shared chat. 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 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
#[must_use]
pub fn chat_id<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.chat_id = val.into();
this
}
/// Title of the chat, if the title was requested by the bot.
#[must_use]
pub fn title<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.title = Some(val.into());
this
}
/// Title of the chat, if the title was requested by the bot.
#[must_use]
pub fn title_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.title = val.map(Into::into);
this
}
/// Username of the chat, if the username was requested by the bot and available.
#[must_use]
pub fn username<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.username = Some(val.into());
this
}
/// Username of the chat, if the username was requested by the bot and available.
#[must_use]
pub fn username_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.username = val.map(Into::into);
this
}
/// Available sizes of the chat photo, if the photo was requested by the bot
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn photos<T: Into<Box<[crate::types::PhotoSize]>>>(self, val: T) -> Self {
let mut this = self;
this.photo = Some(
this.photo
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(val.into())
.collect(),
);
this
}
/// Available sizes of the chat photo, if the photo was requested by the bot
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn photo<T: Into<crate::types::PhotoSize>>(self, val: T) -> Self {
let mut this = self;
this.photo = Some(
this.photo
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(Some(val.into()))
.collect(),
);
this
}
/// Available sizes of the chat photo, if the photo was requested by the bot
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn photo_option<T: Into<Box<[crate::types::PhotoSize]>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.photo = val.map(Into::into);
this
}
}