Skip serializing nones with #[serde_with_macros::skip_serializing_none] instead of many #[serde(skip_serializing_if = "Option::is_none")]

This commit is contained in:
Waffle 2019-12-30 13:44:22 +03:00
parent 95315c6c6e
commit 7377467592
52 changed files with 56 additions and 168 deletions

View file

@ -4,6 +4,7 @@ use crate::types::PhotoSize;
/// without sound). /// without sound).
/// ///
/// [The official docs](https://core.telegram.org/bots/api#animation). /// [The official docs](https://core.telegram.org/bots/api#animation).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Animation { pub struct Animation {
/// An identifier for this file. /// An identifier for this file.

View file

@ -4,6 +4,7 @@ use crate::types::PhotoSize;
/// clients. /// clients.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#audio). /// [The official docs](https://core.telegram.org/bots/api#audio).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Audio { pub struct Audio {
/// An identifier for this file. /// An identifier for this file.

View file

@ -1,4 +1,5 @@
/// A placeholder, currently holds no information. Use [@BotFather](https://t.me/botfather) to set up your game. /// A placeholder, currently holds no information. Use [@BotFather](https://t.me/botfather) to set up your game.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#callbackgame). /// [The official docs](https://core.telegram.org/bots/api#callbackgame).
// TODO: derives?
pub struct CallbackGame; pub struct CallbackGame;

View file

@ -11,6 +11,7 @@ use crate::types::{Message, User};
/// ///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [inline mode]: https://core.telegram.org/bots/api#inline-mode /// [inline mode]: https://core.telegram.org/bots/api#inline-mode
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct CallbackQuery { pub struct CallbackQuery {
/// An unique identifier for this query. /// An unique identifier for this query.

View file

@ -3,6 +3,7 @@ use crate::types::{ChatPermissions, ChatPhoto, Message};
/// This object represents a chat. /// This object represents a chat.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#chat). /// [The official docs](https://core.telegram.org/bots/api#chat).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Chat { pub struct Chat {
/// A unique identifier for this chat. This number may be greater than 32 /// A unique identifier for this chat. This number may be greater than 32
@ -21,6 +22,7 @@ pub struct Chat {
pub photo: Option<ChatPhoto>, pub photo: Option<ChatPhoto>,
} }
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum ChatKind { pub enum ChatKind {
@ -74,6 +76,7 @@ pub enum ChatKind {
}, },
} }
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
#[serde(tag = "type")] #[serde(tag = "type")]

View file

@ -2,45 +2,38 @@
/// chat. /// chat.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#chatpermissions). /// [The official docs](https://core.telegram.org/bots/api#chatpermissions).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ChatPermissions { pub struct ChatPermissions {
/// `true`, if the user is allowed to send text messages, contacts, /// `true`, if the user is allowed to send text messages, contacts,
/// locations and venues. /// locations and venues.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_messages: Option<bool>, pub can_send_messages: Option<bool>,
/// `true`, if the user is allowed to send audios, documents, /// `true`, if the user is allowed to send audios, documents,
/// photos, videos, video notes and voice notes, implies /// photos, videos, video notes and voice notes, implies
/// `can_send_messages`. /// `can_send_messages`.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_media_messages: Option<bool>, pub can_send_media_messages: Option<bool>,
/// `true`, if the user is allowed to send polls, implies /// `true`, if the user is allowed to send polls, implies
/// `can_send_messages`. /// `can_send_messages`.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_polls: Option<bool>, pub can_send_polls: Option<bool>,
/// `true`, if the user is allowed to send animations, games, stickers and /// `true`, if the user is allowed to send animations, games, stickers and
/// use inline bots, implies `can_send_media_messages`. /// use inline bots, implies `can_send_media_messages`.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_other_messages: Option<bool>, pub can_send_other_messages: Option<bool>,
/// `true`, if the user is allowed to add web page previews to /// `true`, if the user is allowed to add web page previews to
/// their messages, implies `can_send_media_messages`. /// their messages, implies `can_send_media_messages`.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_web_page_previews: Option<bool>, pub can_add_web_page_previews: Option<bool>,
/// `true`, if the user is allowed to change the chat title, photo and /// `true`, if the user is allowed to change the chat title, photo and
/// other settings. Ignored in public supergroups. /// other settings. Ignored in public supergroups.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_info: Option<bool>, pub can_change_info: Option<bool>,
/// `true`, if the user is allowed to invite new users to the chat. /// `true`, if the user is allowed to invite new users to the chat.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_invite_users: Option<bool>, pub can_invite_users: Option<bool>,
/// `true`, if the user is allowed to pin messages. Ignored in public /// `true`, if the user is allowed to pin messages. Ignored in public
/// supergroups. /// supergroups.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>, pub can_pin_messages: Option<bool>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{Location, User};
/// [The official docs](https://core.telegram.org/bots/api#choseninlineresult). /// [The official docs](https://core.telegram.org/bots/api#choseninlineresult).
/// ///
/// [result]: https://core.telegram.org/bots/api#inlinequeryresult /// [result]: https://core.telegram.org/bots/api#inlinequeryresult
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ChosenInlineResult { pub struct ChosenInlineResult {
/// The unique identifier for the result that was chosen. /// The unique identifier for the result that was chosen.

View file

@ -1,6 +1,7 @@
/// This object represents a phone contact. /// This object represents a phone contact.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#contact). /// [The official docs](https://core.telegram.org/bots/api#contact).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Contact { pub struct Contact {
/// A contact's phone number. /// A contact's phone number.

View file

@ -8,6 +8,7 @@ use crate::types::PhotoSize;
/// [photos]: https://core.telegram.org/bots/api#photosize /// [photos]: https://core.telegram.org/bots/api#photosize
/// [voice messages]: https://core.telegram.org/bots/api#voice /// [voice messages]: https://core.telegram.org/bots/api#voice
/// [audio files]: https://core.telegram.org/bots/api#audio /// [audio files]: https://core.telegram.org/bots/api#audio
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Document { pub struct Document {
/// An identifier for this file. /// An identifier for this file.

View file

@ -7,6 +7,7 @@
/// [`EncryptedPassportElement`]: /// [`EncryptedPassportElement`]:
/// crate::types::EncryptedPassportElement /// crate::types::EncryptedPassportElement
/// [Telegram Passport Documentation]: https://core.telegram.org/passport#receiving-information /// [Telegram Passport Documentation]: https://core.telegram.org/passport#receiving-information
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct EncryptedCredentials { pub struct EncryptedCredentials {
/// Base64-encoded encrypted JSON-serialized data with unique user's /// Base64-encoded encrypted JSON-serialized data with unique user's

View file

@ -17,6 +17,7 @@ pub struct EncryptedPassportElement {
pub kind: EncryptedPassportElementKind, pub kind: EncryptedPassportElementKind,
} }
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum EncryptedPassportElementKind { pub enum EncryptedPassportElementKind {

View file

@ -14,6 +14,7 @@ pub struct File {
/// File size, if known. /// File size, if known.
pub file_size: u32, pub file_size: u32,
// TODO: chacge "Use ..." to use bot.download...
/// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>` /// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>`
/// to get the file. /// to get the file.
pub file_path: String, pub file_path: String,

View file

@ -9,6 +9,7 @@ use crate::types::True;
/// [The official docs](https://core.telegram.org/bots/api#forcereply). /// [The official docs](https://core.telegram.org/bots/api#forcereply).
/// ///
/// [privacy mode]: https://core.telegram.org/bots#privacy-mode /// [privacy mode]: https://core.telegram.org/bots#privacy-mode
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ForceReply { pub struct ForceReply {
/// Shows reply interface to the user, as if they manually selected the /// Shows reply interface to the user, as if they manually selected the
@ -21,6 +22,5 @@ pub struct ForceReply {
/// (has reply_to_message_id), sender of the original message. /// (has reply_to_message_id), sender of the original message.
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
#[serde(skip_serializing_if = "Option::is_none")]
pub selective: Option<bool>, pub selective: Option<bool>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{Animation, MessageEntity, PhotoSize};
/// their short names will act as unique identifiers. /// their short names will act as unique identifiers.
/// ///
/// [@Botfather]: https://t.me/botfather /// [@Botfather]: https://t.me/botfather
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Game { pub struct Game {
/// Title of the game. /// Title of the game.

View file

@ -4,6 +4,7 @@ use crate::types::{Location, User};
/// empty query, your bot could return some default or trending results. /// empty query, your bot could return some default or trending results.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequery). /// [The official docs](https://core.telegram.org/bots/api#inlinequery).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQuery { pub struct InlineQuery {
/// Unique identifier for this query. /// Unique identifier for this query.

View file

@ -3,6 +3,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent};
/// Represents a link to an article or web page. /// Represents a link to an article or web page.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultarticle). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultarticle).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultArticle { pub struct InlineQueryResultArticle {
/// Unique identifier for this result, 1-64 Bytes. /// Unique identifier for this result, 1-64 Bytes.
@ -15,31 +16,24 @@ pub struct InlineQueryResultArticle {
pub input_message_content: InputMessageContent, pub input_message_content: InputMessageContent,
/// Inline keyboard attached to the message. /// Inline keyboard attached to the message.
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// URL of the result. /// URL of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>, pub url: Option<String>,
/// Pass `true`, if you don't want the URL to be shown in the /// Pass `true`, if you don't want the URL to be shown in the
/// message. /// message.
#[serde(skip_serializing_if = "Option::is_none")]
pub hide_url: Option<bool>, pub hide_url: Option<bool>,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Url of the thumbnail for the result. /// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width. /// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height. /// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -5,6 +5,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// a message with the specified content instead of the audio. /// a message with the specified content instead of the audio.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultaudio). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultaudio).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultAudio { pub struct InlineQueryResultAudio {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -17,7 +18,6 @@ pub struct InlineQueryResultAudio {
pub title: String, pub title: String,
/// Caption, 0-1024 characters. /// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -26,24 +26,19 @@ pub struct InlineQueryResultAudio {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// Performer. /// Performer.
#[serde(skip_serializing_if = "Option::is_none")]
pub performer: Option<String>, pub performer: Option<String>,
/// Audio duration in seconds. /// Audio duration in seconds.
#[serde(skip_serializing_if = "Option::is_none")]
pub audio_duration: Option<String>, pub audio_duration: Option<String>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the audio. /// Content of the message to be sent instead of the audio.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// instead of the audio. /// instead of the audio.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedaudio). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedaudio).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedAudio { pub struct InlineQueryResultCachedAudio {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -15,7 +16,6 @@ pub struct InlineQueryResultCachedAudio {
pub audio_file_id: String, pub audio_file_id: String,
/// Caption, 0-1024 characters. /// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -24,16 +24,13 @@ pub struct InlineQueryResultCachedAudio {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the audio. /// Content of the message to be sent instead of the audio.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// instead of the file. /// instead of the file.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcacheddocument). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcacheddocument).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedDocument { pub struct InlineQueryResultCachedDocument {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -18,11 +19,9 @@ pub struct InlineQueryResultCachedDocument {
pub document_file_id: String, pub document_file_id: String,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the document to be sent, 0-1024 characters. /// Caption of the document to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -31,16 +30,13 @@ pub struct InlineQueryResultCachedDocument {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the file. /// Content of the message to be sent instead of the file.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// message with specified content instead of the animation. /// message with specified content instead of the animation.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedgif). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedgif).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedGif { pub struct InlineQueryResultCachedGif {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -15,11 +16,9 @@ pub struct InlineQueryResultCachedGif {
pub gif_file_id: String, pub gif_file_id: String,
/// Title for the result. /// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the GIF file to be sent, 0-1024 characters. /// Caption of the GIF file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [`ParseMode::Markdown`] or [`ParseMode::HTML`], if you want /// Send [`ParseMode::Markdown`] or [`ParseMode::HTML`], if you want
@ -29,16 +28,13 @@ pub struct InlineQueryResultCachedGif {
/// [`ParseMode::Markdown`]: crate::types::ParseMode::Markdown /// [`ParseMode::Markdown`]: crate::types::ParseMode::Markdown
/// [`ParseMode::HTML`]: crate::types::ParseMode::HTML /// [`ParseMode::HTML`]: crate::types::ParseMode::HTML
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the GIF animation. /// Content of the message to be sent instead of the GIF animation.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -7,6 +7,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// instead of the animation. /// instead of the animation.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedMpeg4Gif { pub struct InlineQueryResultCachedMpeg4Gif {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -16,11 +17,9 @@ pub struct InlineQueryResultCachedMpeg4Gif {
pub mpeg4_file_id: String, pub mpeg4_file_id: String,
/// Title for the result. /// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the MPEG-4 file to be sent, 0-1024 characters. /// Caption of the MPEG-4 file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -29,16 +28,13 @@ pub struct InlineQueryResultCachedMpeg4Gif {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video animation. /// Content of the message to be sent instead of the video animation.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// content instead of the photo. /// content instead of the photo.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedphoto). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedphoto).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedPhoto { pub struct InlineQueryResultCachedPhoto {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -15,15 +16,12 @@ pub struct InlineQueryResultCachedPhoto {
pub photo_file_id: String, pub photo_file_id: String,
/// Title for the result. /// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the photo to be sent, 0-1024 characters. /// Caption of the photo to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -32,16 +30,13 @@ pub struct InlineQueryResultCachedPhoto {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the photo. /// Content of the message to be sent instead of the photo.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent};
/// of the sticker. /// of the sticker.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedsticker). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedsticker).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedSticker { pub struct InlineQueryResultCachedSticker {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -17,10 +18,8 @@ pub struct InlineQueryResultCachedSticker {
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the sticker. /// Content of the message to be sent instead of the sticker.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// the specified content instead of the video. /// the specified content instead of the video.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedVideo { pub struct InlineQueryResultCachedVideo {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -18,11 +19,9 @@ pub struct InlineQueryResultCachedVideo {
pub title: String, pub title: String,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the video to be sent, 0-1024 characters. /// Caption of the video to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -31,16 +30,13 @@ pub struct InlineQueryResultCachedVideo {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video. /// Content of the message to be sent instead of the video.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// instead of the voice message. /// instead of the voice message.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedVoice { pub struct InlineQueryResultCachedVoice {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -18,7 +19,6 @@ pub struct InlineQueryResultCachedVoice {
pub title: String, pub title: String,
/// Caption, 0-1024 characters. /// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -27,16 +27,13 @@ pub struct InlineQueryResultCachedVoice {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the voice message. /// Content of the message to be sent instead of the voice message.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -5,6 +5,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent};
/// a message with the specified content instead of the contact. /// a message with the specified content instead of the contact.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultContact { pub struct InlineQueryResultContact {
/// Unique identifier for this result, 1-64 Bytes. /// Unique identifier for this result, 1-64 Bytes.
@ -17,35 +18,28 @@ pub struct InlineQueryResultContact {
pub first_name: String, pub first_name: String,
/// Contact's last name. /// Contact's last name.
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>, pub last_name: Option<String>,
/// Additional data about the contact in the form of a [vCard], 0-2048 /// Additional data about the contact in the form of a [vCard], 0-2048
/// bytes. /// bytes.
/// ///
/// [VCard]: https://en.wikipedia.org/wiki/VCard /// [VCard]: https://en.wikipedia.org/wiki/VCard
#[serde(skip_serializing_if = "Option::is_none")]
pub vcard: Option<String>, pub vcard: Option<String>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the contact. /// Content of the message to be sent instead of the contact.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// Url of the thumbnail for the result. /// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width. /// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height. /// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// only **.PDF** and **.ZIP** files can be sent using this method. /// only **.PDF** and **.ZIP** files can be sent using this method.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultdocument). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultdocument).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultDocument { pub struct InlineQueryResultDocument {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -15,7 +16,6 @@ pub struct InlineQueryResultDocument {
pub title: String, pub title: String,
/// Caption of the document to be sent, 0-1024 characters. /// Caption of the document to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -24,7 +24,6 @@ pub struct InlineQueryResultDocument {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// A valid URL for the file. /// A valid URL for the file.
@ -35,26 +34,20 @@ pub struct InlineQueryResultDocument {
pub mime_type: String, pub mime_type: String,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Inline keyboard attached to the message. /// Inline keyboard attached to the message.
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the file. /// Content of the message to be sent instead of the file.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// URL of the thumbnail (jpeg only) for the file. /// URL of the thumbnail (jpeg only) for the file.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width. /// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height. /// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -5,6 +5,7 @@ use crate::types::InlineKeyboardMarkup;
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgame). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgame).
/// ///
/// [game]: https://core.telegram.org/bots/api#games /// [game]: https://core.telegram.org/bots/api#games
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct InlineQueryResultGame { pub struct InlineQueryResultGame {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -16,6 +17,5 @@ pub struct InlineQueryResultGame {
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// instead of the animation. /// instead of the animation.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgif). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgif).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultGif { pub struct InlineQueryResultGif {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -15,26 +16,21 @@ pub struct InlineQueryResultGif {
pub gif_url: String, pub gif_url: String,
/// Width of the GIF. /// Width of the GIF.
#[serde(skip_serializing_if = "Option::is_none")]
pub gif_width: Option<i32>, pub gif_width: Option<i32>,
/// Height of the GIFv. /// Height of the GIFv.
#[serde(skip_serializing_if = "Option::is_none")]
pub gif_height: Option<i32>, pub gif_height: Option<i32>,
/// Duration of the GIF. /// Duration of the GIF.
#[serde(skip_serializing_if = "Option::is_none")]
pub gif_duration: Option<i32>, pub gif_duration: Option<i32>,
/// URL of the static thumbnail for the result (jpeg or gif). /// URL of the static thumbnail for the result (jpeg or gif).
pub thumb_url: String, pub thumb_url: String,
/// Title for the result. /// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the GIF file to be sent, 0-1024 characters. /// Caption of the GIF file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -43,16 +39,13 @@ pub struct InlineQueryResultGif {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the GIF animation. /// Content of the message to be sent instead of the GIF animation.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -5,6 +5,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent};
/// with the specified content instead of the location. /// with the specified content instead of the location.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultlocation). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultlocation).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultLocation { pub struct InlineQueryResultLocation {
/// Unique identifier for this result, 1-64 Bytes. /// Unique identifier for this result, 1-64 Bytes.
@ -21,28 +22,22 @@ pub struct InlineQueryResultLocation {
/// Period in seconds for which the location can be updated, should be /// Period in seconds for which the location can be updated, should be
/// between 60 and 86400. /// between 60 and 86400.
#[serde(skip_serializing_if = "Option::is_none")]
pub live_period: Option<i32>, pub live_period: Option<i32>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the location. /// Content of the message to be sent instead of the location.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// Url of the thumbnail for the result. /// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width. /// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height. /// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// a message with the specified content instead of the animation. /// a message with the specified content instead of the animation.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultMpeg4Gif { pub struct InlineQueryResultMpeg4Gif {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -15,26 +16,21 @@ pub struct InlineQueryResultMpeg4Gif {
pub mpeg4_url: String, pub mpeg4_url: String,
/// Video width. /// Video width.
#[serde(skip_serializing_if = "Option::is_none")]
pub mpeg4_width: Option<i32>, pub mpeg4_width: Option<i32>,
/// Video height. /// Video height.
#[serde(skip_serializing_if = "Option::is_none")]
pub mpeg4_height: Option<i32>, pub mpeg4_height: Option<i32>,
/// Video duration. /// Video duration.
#[serde(skip_serializing_if = "Option::is_none")]
pub mpeg4_duration: Option<i32>, pub mpeg4_duration: Option<i32>,
/// URL of the static thumbnail (jpeg or gif) for the result. /// URL of the static thumbnail (jpeg or gif) for the result.
pub thumb_url: String, pub thumb_url: String,
/// Title for the result. /// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the MPEG-4 file to be sent, 0-1024 characters. /// Caption of the MPEG-4 file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -43,16 +39,13 @@ pub struct InlineQueryResultMpeg4Gif {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video animation. /// Content of the message to be sent instead of the video animation.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// of the photo. /// of the photo.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultphoto). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultphoto).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultPhoto { pub struct InlineQueryResultPhoto {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -19,23 +20,18 @@ pub struct InlineQueryResultPhoto {
pub thumb_url: String, pub thumb_url: String,
/// Width of the photo. /// Width of the photo.
#[serde(skip_serializing_if = "Option::is_none")]
pub photo_width: Option<i32>, pub photo_width: Option<i32>,
/// Height of the photo. /// Height of the photo.
#[serde(skip_serializing_if = "Option::is_none")]
pub photo_height: Option<i32>, pub photo_height: Option<i32>,
/// Title for the result. /// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the photo to be sent, 0-1024 characters. /// Caption of the photo to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -44,16 +40,13 @@ pub struct InlineQueryResultPhoto {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the photo. /// Content of the message to be sent instead of the photo.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -5,6 +5,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent};
/// the specified content instead of the venue. /// the specified content instead of the venue.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvenue). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvenue).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultVenue { pub struct InlineQueryResultVenue {
/// Unique identifier for this result, 1-64 Bytes. /// Unique identifier for this result, 1-64 Bytes.
@ -23,34 +24,27 @@ pub struct InlineQueryResultVenue {
pub address: String, pub address: String,
/// Foursquare identifier of the venue if known. /// Foursquare identifier of the venue if known.
#[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_id: Option<String>, pub foursquare_id: Option<String>,
/// Foursquare type of the venue, if known. (For example, /// Foursquare type of the venue, if known. (For example,
/// `arts_entertainment/default`, `arts_entertainment/aquarium` or /// `arts_entertainment/default`, `arts_entertainment/aquarium` or
/// `food/icecream`.) /// `food/icecream`.)
#[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_type: Option<String>, pub foursquare_type: Option<String>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the venue. /// Content of the message to be sent instead of the venue.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// Url of the thumbnail for the result. /// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width. /// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height. /// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// message with the specified content instead of the video. /// message with the specified content instead of the video.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvideo). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvideo).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultVideo { pub struct InlineQueryResultVideo {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -24,7 +25,6 @@ pub struct InlineQueryResultVideo {
pub title: String, pub title: String,
/// Caption of the video to be sent, 0-1024 characters. /// Caption of the video to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -33,29 +33,23 @@ pub struct InlineQueryResultVideo {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// Video width. /// Video width.
#[serde(skip_serializing_if = "Option::is_none")]
pub video_width: Option<i32>, pub video_width: Option<i32>,
/// Video height. /// Video height.
#[serde(skip_serializing_if = "Option::is_none")]
pub video_height: Option<i32>, pub video_height: Option<i32>,
/// Video duration in seconds. /// Video duration in seconds.
#[serde(skip_serializing_if = "Option::is_none")]
pub video_duration: Option<i32>, pub video_duration: Option<i32>,
/// Short description of the result. /// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video. This field is /// Content of the message to be sent instead of the video. This field is
@ -64,6 +58,5 @@ pub struct InlineQueryResultVideo {
/// ///
/// [`InlineQueryResultVideo`]: /// [`InlineQueryResultVideo`]:
/// crate::types::InlineQueryResultVideo /// crate::types::InlineQueryResultVideo
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -6,6 +6,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// the specified content instead of the the voice message. /// the specified content instead of the the voice message.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvoice). /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvoice).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultVoice { pub struct InlineQueryResultVoice {
/// Unique identifier for this result, 1-64 bytes. /// Unique identifier for this result, 1-64 bytes.
@ -18,7 +19,6 @@ pub struct InlineQueryResultVoice {
pub title: String, pub title: String,
/// Caption, 0-1024 characters. /// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -27,20 +27,16 @@ pub struct InlineQueryResultVoice {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// Recording duration in seconds. /// Recording duration in seconds.
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_duration: Option<i32>, pub voice_duration: Option<i32>,
/// [Inline keyboard] attached to the message. /// [Inline keyboard] attached to the message.
/// ///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the voice recording. /// Content of the message to be sent instead of the voice recording.
#[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,6 +1,7 @@
use crate::types::{InputFile, ParseMode}; use crate::types::{InputFile, ParseMode};
// TODO: should variants use new-type? // TODO: should variants use new-type?
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
@ -16,7 +17,6 @@ pub enum InputMedia {
media: InputFile, media: InputFile,
/// Caption of the photo to be sent, 0-1024 characters. /// Caption of the photo to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -25,7 +25,6 @@ pub enum InputMedia {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
}, },
@ -41,11 +40,9 @@ pub enum InputMedia {
/// JPEG format and less than 200 kB in size. A thumbnails width and /// JPEG format and less than 200 kB in size. A thumbnails width and
/// height should not exceed 320. Ignored if the file is not uploaded /// height should not exceed 320. Ignored if the file is not uploaded
/// using multipart/form-data. /// using multipart/form-data.
#[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the video to be sent, 0-1024 characters. /// Caption of the video to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -54,23 +51,18 @@ pub enum InputMedia {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// Video width. /// Video width.
#[serde(skip_serializing_if = "Option::is_none")]
width: Option<u16>, width: Option<u16>,
/// Video height. /// Video height.
#[serde(skip_serializing_if = "Option::is_none")]
height: Option<u16>, height: Option<u16>,
/// Video duration. /// Video duration.
#[serde(skip_serializing_if = "Option::is_none")]
duration: Option<u16>, duration: Option<u16>,
/// Pass `true`, if the uploaded video is suitable for streaming. /// Pass `true`, if the uploaded video is suitable for streaming.
#[serde(skip_serializing_if = "Option::is_none")]
supports_streaming: Option<bool>, supports_streaming: Option<bool>,
}, },
@ -87,11 +79,9 @@ pub enum InputMedia {
/// JPEG format and less than 200 kB in size. A thumbnails width and /// JPEG format and less than 200 kB in size. A thumbnails width and
/// height should not exceed 320. Ignored if the file is not uploaded /// height should not exceed 320. Ignored if the file is not uploaded
/// using multipart/form-data. /// using multipart/form-data.
#[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the animation to be sent, 0-1024 characters. /// Caption of the animation to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -100,19 +90,15 @@ pub enum InputMedia {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// Animation width. /// Animation width.
#[serde(skip_serializing_if = "Option::is_none")]
width: Option<u16>, width: Option<u16>,
/// Animation height. /// Animation height.
#[serde(skip_serializing_if = "Option::is_none")]
height: Option<u16>, height: Option<u16>,
/// Animation duration. /// Animation duration.
#[serde(skip_serializing_if = "Option::is_none")]
duration: Option<u16>, duration: Option<u16>,
}, },
@ -128,11 +114,9 @@ pub enum InputMedia {
/// JPEG format and less than 200 kB in size. A thumbnails width and /// JPEG format and less than 200 kB in size. A thumbnails width and
/// height should not exceed 320. Ignored if the file is not uploaded /// height should not exceed 320. Ignored if the file is not uploaded
/// using multipart/form-data. /// using multipart/form-data.
#[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the audio to be sent, 0-1024 characters. /// Caption of the audio to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -141,19 +125,15 @@ pub enum InputMedia {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<String>, parse_mode: Option<String>,
/// Duration of the audio in seconds. /// Duration of the audio in seconds.
#[serde(skip_serializing_if = "Option::is_none")]
duration: Option<u16>, duration: Option<u16>,
/// Performer of the audio. /// Performer of the audio.
#[serde(skip_serializing_if = "Option::is_none")]
performer: Option<String>, performer: Option<String>,
/// Title of the audio. /// Title of the audio.
#[serde(skip_serializing_if = "Option::is_none")]
title: Option<String>, title: Option<String>,
}, },
@ -169,11 +149,9 @@ pub enum InputMedia {
/// JPEG format and less than 200 kB in size. A thumbnails width and /// JPEG format and less than 200 kB in size. A thumbnails width and
/// height should not exceed 320. Ignored if the file is not uploaded /// height should not exceed 320. Ignored if the file is not uploaded
/// using multipart/form-data. /// using multipart/form-data.
#[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the document to be sent, 0-1024 charactersю /// Caption of the document to be sent, 0-1024 charactersю
#[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
@ -182,7 +160,6 @@ pub enum InputMedia {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
}, },
} }

View file

@ -2,6 +2,7 @@ use serde::Serialize;
use crate::types::ParseMode; use crate::types::ParseMode;
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
/// This object represents the content of a message to be sent as a result of an /// This object represents the content of a message to be sent as a result of an
@ -21,11 +22,9 @@ pub enum InputMessageContent {
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: https://core.telegram.org/bots/api#html-style /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// Disables link previews for links in the sent message. /// Disables link previews for links in the sent message.
#[serde(skip_serializing_if = "Option::is_none")]
disable_web_page_preview: Option<bool>, disable_web_page_preview: Option<bool>,
}, },
@ -40,7 +39,6 @@ pub enum InputMessageContent {
/// Period in seconds for which the location can be updated, should be /// Period in seconds for which the location can be updated, should be
/// between 60 and 86400. /// between 60 and 86400.
#[serde(skip_serializing_if = "Option::is_none")]
live_period: Option<u32>, live_period: Option<u32>,
}, },
@ -60,13 +58,11 @@ pub enum InputMessageContent {
address: String, address: String,
/// Foursquare identifier of the venue, if known. /// Foursquare identifier of the venue, if known.
#[serde(skip_serializing_if = "Option::is_none")]
foursquare_id: Option<String>, foursquare_id: Option<String>,
/// Foursquare type of the venue, if known. (For example, /// Foursquare type of the venue, if known. (For example,
/// `arts_entertainment/default`, `arts_entertainment/aquarium` /// `arts_entertainment/default`, `arts_entertainment/aquarium`
/// or `food/icecream`.) /// or `food/icecream`.)
#[serde(skip_serializing_if = "Option::is_none")]
foursquare_type: Option<String>, foursquare_type: Option<String>,
}, },
@ -80,14 +76,12 @@ pub enum InputMessageContent {
first_name: String, first_name: String,
/// Contact's last name. /// Contact's last name.
#[serde(skip_serializing_if = "Option::is_none")]
last_name: Option<String>, last_name: Option<String>,
/// Additional data about the contact in the form of a [vCard], 0-2048 /// Additional data about the contact in the form of a [vCard], 0-2048
/// bytes. /// bytes.
/// ///
/// [vCard]: https://en.wikipedia.org/wiki/VCard /// [vCard]: https://en.wikipedia.org/wiki/VCard
#[serde(skip_serializing_if = "Option::is_none")]
vcard: Option<String>, vcard: Option<String>,
}, },
} }

View file

@ -8,16 +8,11 @@
/// </div> /// </div>
/// ///
/// [Telegram Login Widget]: https://core.telegram.org/widgets/login /// [Telegram Login Widget]: https://core.telegram.org/widgets/login
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct LoginUrl { pub struct LoginUrl {
pub url: String, pub url: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub forward_text: Option<String>, pub forward_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bot_username: Option<String>, pub bot_username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub request_write_access: Option<bool>, pub request_write_access: Option<bool>,
} }

View file

@ -25,6 +25,7 @@ pub struct Message {
pub kind: MessageKind, pub kind: MessageKind,
} }
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum MessageKind { pub enum MessageKind {

View file

@ -2,6 +2,7 @@
/// ///
/// [file]: crate::types::Document /// [file]: crate::types::Document
/// [sticker]: crate::types::Sticker /// [sticker]: crate::types::Sticker
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PhotoSize { pub struct PhotoSize {
/// Identifier for this file. /// Identifier for this file.

View file

@ -3,6 +3,7 @@ use crate::types::{OrderInfo, User};
/// This object contains information about an incoming pre-checkout query. /// This object contains information about an incoming pre-checkout query.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#precheckoutquery). /// [The official docs](https://core.telegram.org/bots/api#precheckoutquery).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PreCheckoutQuery { pub struct PreCheckoutQuery {
/// Unique query identifier. /// Unique query identifier.

View file

@ -7,6 +7,7 @@ use crate::types::KeyboardButton;
/// ///
/// [custom keyboard]: https://core.telegram.org/bots#keyboards /// [custom keyboard]: https://core.telegram.org/bots#keyboards
/// [Introduction to bots]: https://core.telegram.org/bots#keyboards /// [Introduction to bots]: https://core.telegram.org/bots#keyboards
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ReplyKeyboardMarkup { pub struct ReplyKeyboardMarkup {
/// Array of button rows, each represented by an Array of /// Array of button rows, each represented by an Array of
@ -19,7 +20,6 @@ pub struct ReplyKeyboardMarkup {
/// (e.g., make the keyboard smaller if there are just two rows of /// (e.g., make the keyboard smaller if there are just two rows of
/// buttons). Defaults to `false`, in which case the custom keyboard is /// buttons). Defaults to `false`, in which case the custom keyboard is
/// always of the same height as the app's standard keyboard. /// always of the same height as the app's standard keyboard.
#[serde(skip_serializing_if = "Option::is_none")]
pub resize_keyboard: Option<bool>, pub resize_keyboard: Option<bool>,
/// Requests clients to hide the keyboard as soon as it's been used. The /// Requests clients to hide the keyboard as soon as it's been used. The
@ -27,7 +27,6 @@ pub struct ReplyKeyboardMarkup {
/// display the usual letter-keyboard in the chat the user can press a /// display the usual letter-keyboard in the chat the user can press a
/// special button in the input field to see the custom keyboard again. /// special button in the input field to see the custom keyboard again.
/// Defaults to `false`. /// Defaults to `false`.
#[serde(skip_serializing_if = "Option::is_none")]
pub one_time_keyboard: Option<bool>, pub one_time_keyboard: Option<bool>,
/// Use this parameter if you want to show the keyboard to specific users /// Use this parameter if you want to show the keyboard to specific users
@ -40,6 +39,5 @@ pub struct ReplyKeyboardMarkup {
/// in the group dont see the keyboard. /// in the group dont see the keyboard.
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
#[serde(skip_serializing_if = "Option::is_none")]
pub selective: Option<bool>, pub selective: Option<bool>,
} }

View file

@ -9,6 +9,7 @@ use crate::types::True;
/// [The official docs](https://core.telegram.org/bots/api#replykeyboardremove). /// [The official docs](https://core.telegram.org/bots/api#replykeyboardremove).
/// ///
/// [`ReplyKeyboardMarkup`]: crate::types::ReplyKeyboardMarkup /// [`ReplyKeyboardMarkup`]: crate::types::ReplyKeyboardMarkup
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ReplyKeyboardRemove { pub struct ReplyKeyboardRemove {
/// Requests clients to remove the custom keyboard (user will not be able /// Requests clients to remove the custom keyboard (user will not be able
@ -29,6 +30,5 @@ pub struct ReplyKeyboardRemove {
/// showing the keyboard with poll options to users who haven't voted yet. /// showing the keyboard with poll options to users who haven't voted yet.
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
#[serde(skip_serializing_if = "Option::is_none")]
pub selective: Option<bool>, pub selective: Option<bool>,
} }

View file

@ -1,5 +1,7 @@
use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice}; use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice};
// TODO: missing docs
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct SendInvoice { pub struct SendInvoice {
pub chat_id: ChatId, pub chat_id: ChatId,

View file

@ -3,6 +3,7 @@ use crate::types::{MaskPosition, PhotoSize};
/// This object represents a sticker. /// This object represents a sticker.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#sticker). /// [The official docs](https://core.telegram.org/bots/api#sticker).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Sticker { pub struct Sticker {
/// Identifier for this file. /// Identifier for this file.

View file

@ -3,6 +3,7 @@ use crate::types::OrderInfo;
/// This object contains basic information about a successful payment. /// This object contains basic information about a successful payment.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#successfulpayment). /// [The official docs](https://core.telegram.org/bots/api#successfulpayment).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct SuccessfulPayment { pub struct SuccessfulPayment {
/// Three-letter ISO 4217 [currency] code. /// Three-letter ISO 4217 [currency] code.

View file

@ -1,6 +1,7 @@
/// This object represents a Telegram user or bot. /// This object represents a Telegram user or bot.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#user). /// [The official docs](https://core.telegram.org/bots/api#user).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct User { pub struct User {
/// Unique identifier for this user or bot. /// Unique identifier for this user or bot.

View file

@ -1,6 +1,7 @@
use crate::types::Location; use crate::types::Location;
/// This object represents a venue. /// This object represents a venue.
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Venue { pub struct Venue {
/// Venue location. /// Venue location.
@ -13,12 +14,10 @@ pub struct Venue {
pub address: String, pub address: String,
/// Foursquare identifier of the venue. /// Foursquare identifier of the venue.
#[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_id: Option<String>, pub foursquare_id: Option<String>,
/// Foursquare type of the venue. (For example, /// Foursquare type of the venue. (For example,
/// `arts_entertainment/default`, `arts_entertainment/aquarium` or /// `arts_entertainment/default`, `arts_entertainment/aquarium` or
/// `food/icecream`.) /// `food/icecream`.)
#[serde(skip_serializing_if = "Option::is_none")] pub foursquare_type: Option<String>,
pub foursquare_type: Option<String>, // TODO: is this enum?...
} }

View file

@ -3,6 +3,7 @@ use crate::types::PhotoSize;
/// This object represents a video file. /// This object represents a video file.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#video). /// [The official docs](https://core.telegram.org/bots/api#video).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Video { pub struct Video {
/// Identifier for this file. /// Identifier for this file.

View file

@ -7,6 +7,7 @@ use crate::types::PhotoSize;
/// ///
/// [video message]: https://telegram.org/blog/video-messages-and-telescope /// [video message]: https://telegram.org/blog/video-messages-and-telescope
/// [v4.0]: https://telegram.org/blog/video-messages-and-telescope /// [v4.0]: https://telegram.org/blog/video-messages-and-telescope
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct VideoNote { pub struct VideoNote {
/// Identifier for this file. /// Identifier for this file.

View file

@ -1,6 +1,7 @@
/// This object represents a voice note. /// This object represents a voice note.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#voice). /// [The official docs](https://core.telegram.org/bots/api#voice).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Voice { pub struct Voice {
/// Identifier for this file. /// Identifier for this file.

View file

@ -1,6 +1,7 @@
/// Contains information about the current status of a webhook. /// Contains information about the current status of a webhook.
/// ///
/// [The official docs](https://core.telegram.org/bots/api#webhookinfo). /// [The official docs](https://core.telegram.org/bots/api#webhookinfo).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct WebhookInfo { pub struct WebhookInfo {
/// Webhook URL, may be empty if webhook is not set up. /// Webhook URL, may be empty if webhook is not set up.