Skip to main content

rustigram_types/
shared.rs

1use serde::{Deserialize, Serialize};
2
3use crate::file::PhotoSize;
4
5/// A user shared with the bot via a
6/// [`KeyboardButtonRequestUsers`](crate::keyboard::KeyboardButtonRequestUsers) button.
7///
8/// The optional name and photo fields are only present when the user granted
9/// the bot access to them.
10#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11#[non_exhaustive]
12pub struct SharedUser {
13    /// Identifier of the shared user.
14    ///
15    /// May have more than 32 significant bits; 64-bit integers are safe for
16    /// storing it. The bot may not have access to the user yet — it only gains
17    /// access once the user sends a message.
18    pub user_id: i64,
19    /// First name of the user, if it was shared.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub first_name: Option<String>,
22    /// Last name of the user, if it was shared.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub last_name: Option<String>,
25    /// Username of the user, if it was shared.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub username: Option<String>,
28    /// Available sizes of the user's photo, if it was shared.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub photo: Option<Vec<PhotoSize>>,
31}
32
33/// Service message: users were shared with the bot.
34#[derive(Debug, Clone, Default, Serialize, Deserialize)]
35#[non_exhaustive]
36pub struct UsersShared {
37    /// Identifier of the request that produced this share.
38    pub request_id: i32,
39    /// Information about the shared users.
40    pub users: Vec<SharedUser>,
41}
42
43/// Service message: a chat was shared with the bot.
44#[derive(Debug, Clone, Default, Serialize, Deserialize)]
45#[non_exhaustive]
46pub struct ChatShared {
47    /// Identifier of the request that produced this share.
48    pub request_id: i32,
49    /// Identifier of the shared chat.
50    ///
51    /// The bot may not have access to the chat yet — it only gains access once
52    /// the chat sends a message or the bot is added to it.
53    pub chat_id: i64,
54    /// Title of the chat, if it was shared.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub title: Option<String>,
57    /// Username of the chat, if it was shared.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub username: Option<String>,
60    /// Available sizes of the chat photo, if it was shared.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub photo: Option<Vec<PhotoSize>>,
63}