diff --git a/logo.svg b/logo.svg new file mode 100644 index 00000000..652bca3d --- /dev/null +++ b/logo.svg @@ -0,0 +1,405 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/errors.rs b/src/errors.rs index e8c1ae21..800453c1 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,4 +1,6 @@ +use derive_more::From; use reqwest::StatusCode; +use thiserror::Error; // #[derive(Debug, Error, From)] diff --git a/src/lib.rs b/src/lib.rs index 1d14fbaa..de96c6be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,8 @@ -#![allow(clippy::unit_arg)] // TODO -#![allow(clippy::ptr_arg)] // TODO #![doc( - html_logo_url = "https://github.com/teloxide/teloxide/raw/dev/ICON.png", + html_logo_url = "https://github.com/teloxide/teloxide/raw/dev/logo.svg", html_favicon_url = "https://github.com/teloxide/teloxide/raw/dev/ICON.png" )] - -#[macro_use] -extern crate derive_more; -#[macro_use] -extern crate serde; -#[macro_use] -extern crate thiserror; +#![allow(clippy::match_bool)] pub use bot::Bot; pub use errors::{DownloadError, RequestError}; diff --git a/src/network/telegram_response.rs b/src/network/telegram_response.rs index 82185c0c..a54b0f77 100644 --- a/src/network/telegram_response.rs +++ b/src/network/telegram_response.rs @@ -1,4 +1,5 @@ use reqwest::StatusCode; +use serde::Deserialize; use crate::{ requests::ResponseResult, diff --git a/src/requests/payloads/add_sticker_to_set.rs b/src/requests/payloads/add_sticker_to_set.rs index 17aee206..21ab6133 100644 --- a/src/requests/payloads/add_sticker_to_set.rs +++ b/src/requests/payloads/add_sticker_to_set.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/answer_callback_query.rs b/src/requests/payloads/answer_callback_query.rs index 02c01741..ab9a99a2 100644 --- a/src/requests/payloads/answer_callback_query.rs +++ b/src/requests/payloads/answer_callback_query.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::True, diff --git a/src/requests/payloads/answer_inline_query.rs b/src/requests/payloads/answer_inline_query.rs index 69a56583..6de79a0f 100644 --- a/src/requests/payloads/answer_inline_query.rs +++ b/src/requests/payloads/answer_inline_query.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::InlineQueryResult, diff --git a/src/requests/payloads/answer_pre_checkout_query.rs b/src/requests/payloads/answer_pre_checkout_query.rs index fa7381d6..1970f981 100644 --- a/src/requests/payloads/answer_pre_checkout_query.rs +++ b/src/requests/payloads/answer_pre_checkout_query.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::True, diff --git a/src/requests/payloads/answer_shipping_query.rs b/src/requests/payloads/answer_shipping_query.rs index 6734cd8f..8c11e3b6 100644 --- a/src/requests/payloads/answer_shipping_query.rs +++ b/src/requests/payloads/answer_shipping_query.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ShippingOption, True}, diff --git a/src/requests/payloads/create_new_sticker_set.rs b/src/requests/payloads/create_new_sticker_set.rs index 396ecd43..7e599b24 100644 --- a/src/requests/payloads/create_new_sticker_set.rs +++ b/src/requests/payloads/create_new_sticker_set.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/delete_chat_photo.rs b/src/requests/payloads/delete_chat_photo.rs index cae67d7d..02a680ab 100644 --- a/src/requests/payloads/delete_chat_photo.rs +++ b/src/requests/payloads/delete_chat_photo.rs @@ -1,7 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, + types::{ChatId, True}, }; -use crate::types::{ChatId, True}; /// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/delete_chat_sticker_set.rs b/src/requests/payloads/delete_chat_sticker_set.rs index c279f217..8ecf702c 100644 --- a/src/requests/payloads/delete_chat_sticker_set.rs +++ b/src/requests/payloads/delete_chat_sticker_set.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/delete_message.rs b/src/requests/payloads/delete_message.rs index f585376a..6fe9a596 100644 --- a/src/requests/payloads/delete_message.rs +++ b/src/requests/payloads/delete_message.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/delete_sticker_from_set.rs b/src/requests/payloads/delete_sticker_from_set.rs index 5b8b7157..11edb2e1 100644 --- a/src/requests/payloads/delete_sticker_from_set.rs +++ b/src/requests/payloads/delete_sticker_from_set.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::True, diff --git a/src/requests/payloads/delete_webhook.rs b/src/requests/payloads/delete_webhook.rs index 903b72ff..fe988ce9 100644 --- a/src/requests/payloads/delete_webhook.rs +++ b/src/requests/payloads/delete_webhook.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::True, diff --git a/src/requests/payloads/edit_message_caption.rs b/src/requests/payloads/edit_message_caption.rs index e965537d..c0cc2584 100644 --- a/src/requests/payloads/edit_message_caption.rs +++ b/src/requests/payloads/edit_message_caption.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ParseMode, InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/edit_message_caption_inline.rs b/src/requests/payloads/edit_message_caption_inline.rs index e0b5a6a5..cfe99d20 100644 --- a/src/requests/payloads/edit_message_caption_inline.rs +++ b/src/requests/payloads/edit_message_caption_inline.rs @@ -1,10 +1,9 @@ - +use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, - types::{ParseMode, InlineKeyboardMarkup}, + types::{ParseMode, InlineKeyboardMarkup, Message}, }; -use crate::types::Message; /// Use this method to edit captions of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/edit_message_live_location.rs b/src/requests/payloads/edit_message_live_location.rs index dc87bae3..c7993b6b 100644 --- a/src/requests/payloads/edit_message_live_location.rs +++ b/src/requests/payloads/edit_message_live_location.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/edit_message_live_location_inline.rs b/src/requests/payloads/edit_message_live_location_inline.rs index a1c742ab..c7d48724 100644 --- a/src/requests/payloads/edit_message_live_location_inline.rs +++ b/src/requests/payloads/edit_message_live_location_inline.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, diff --git a/src/requests/payloads/edit_message_media.rs b/src/requests/payloads/edit_message_media.rs index d827c45c..c9b9deaa 100644 --- a/src/requests/payloads/edit_message_media.rs +++ b/src/requests/payloads/edit_message_media.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/edit_message_media_inline.rs b/src/requests/payloads/edit_message_media_inline.rs index 83cffc58..fde5adfc 100644 --- a/src/requests/payloads/edit_message_media_inline.rs +++ b/src/requests/payloads/edit_message_media_inline.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/edit_message_reply_markup.rs b/src/requests/payloads/edit_message_reply_markup.rs index 0a38d486..5d0a401c 100644 --- a/src/requests/payloads/edit_message_reply_markup.rs +++ b/src/requests/payloads/edit_message_reply_markup.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/edit_message_reply_markup_inline.rs b/src/requests/payloads/edit_message_reply_markup_inline.rs index d93d1556..2f35f728 100644 --- a/src/requests/payloads/edit_message_reply_markup_inline.rs +++ b/src/requests/payloads/edit_message_reply_markup_inline.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, diff --git a/src/requests/payloads/edit_message_text.rs b/src/requests/payloads/edit_message_text.rs index 512b2ead..24f19922 100644 --- a/src/requests/payloads/edit_message_text.rs +++ b/src/requests/payloads/edit_message_text.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ParseMode, InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/edit_message_text_inline.rs b/src/requests/payloads/edit_message_text_inline.rs index 4d3ed7ed..40a87eea 100644 --- a/src/requests/payloads/edit_message_text_inline.rs +++ b/src/requests/payloads/edit_message_text_inline.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ParseMode, InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/export_chat_invite_link.rs b/src/requests/payloads/export_chat_invite_link.rs index 182a24e5..f0cd91c9 100644 --- a/src/requests/payloads/export_chat_invite_link.rs +++ b/src/requests/payloads/export_chat_invite_link.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::ChatId, diff --git a/src/requests/payloads/forward_message.rs b/src/requests/payloads/forward_message.rs index 568f0c7b..0fd04c67 100644 --- a/src/requests/payloads/forward_message.rs +++ b/src/requests/payloads/forward_message.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, Message}, diff --git a/src/requests/payloads/get_chat.rs b/src/requests/payloads/get_chat.rs index 929c914a..76d56d6f 100644 --- a/src/requests/payloads/get_chat.rs +++ b/src/requests/payloads/get_chat.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, Chat}, diff --git a/src/requests/payloads/get_chat_administrators.rs b/src/requests/payloads/get_chat_administrators.rs index f8d2fd77..f61f1245 100644 --- a/src/requests/payloads/get_chat_administrators.rs +++ b/src/requests/payloads/get_chat_administrators.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ChatMember}, diff --git a/src/requests/payloads/get_chat_member.rs b/src/requests/payloads/get_chat_member.rs index 58162dd7..0d0aab63 100644 --- a/src/requests/payloads/get_chat_member.rs +++ b/src/requests/payloads/get_chat_member.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ChatMember}, diff --git a/src/requests/payloads/get_chat_members_count.rs b/src/requests/payloads/get_chat_members_count.rs index e87e8722..9848fdd5 100644 --- a/src/requests/payloads/get_chat_members_count.rs +++ b/src/requests/payloads/get_chat_members_count.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::ChatId, diff --git a/src/requests/payloads/get_file.rs b/src/requests/payloads/get_file.rs index d7614efa..471388ae 100644 --- a/src/requests/payloads/get_file.rs +++ b/src/requests/payloads/get_file.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::File, diff --git a/src/requests/payloads/get_game_high_scores.rs b/src/requests/payloads/get_game_high_scores.rs index 16ac1a3d..34909bed 100644 --- a/src/requests/payloads/get_game_high_scores.rs +++ b/src/requests/payloads/get_game_high_scores.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::GameHighScore, diff --git a/src/requests/payloads/get_game_high_scores_inline.rs b/src/requests/payloads/get_game_high_scores_inline.rs index 666142f1..1c07ce12 100644 --- a/src/requests/payloads/get_game_high_scores_inline.rs +++ b/src/requests/payloads/get_game_high_scores_inline.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::GameHighScore, diff --git a/src/requests/payloads/get_me.rs b/src/requests/payloads/get_me.rs index b2ab1f45..8fe95879 100644 --- a/src/requests/payloads/get_me.rs +++ b/src/requests/payloads/get_me.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, types::User, diff --git a/src/requests/payloads/get_sticker_set.rs b/src/requests/payloads/get_sticker_set.rs index b6660a73..75b0a6f0 100644 --- a/src/requests/payloads/get_sticker_set.rs +++ b/src/requests/payloads/get_sticker_set.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::StickerSet, diff --git a/src/requests/payloads/get_updates.rs b/src/requests/payloads/get_updates.rs index 343826fe..e3c92cee 100644 --- a/src/requests/payloads/get_updates.rs +++ b/src/requests/payloads/get_updates.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::Update, diff --git a/src/requests/payloads/get_user_profile_photos.rs b/src/requests/payloads/get_user_profile_photos.rs index ba564a00..6ef61b56 100644 --- a/src/requests/payloads/get_user_profile_photos.rs +++ b/src/requests/payloads/get_user_profile_photos.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::UserProfilePhotos, diff --git a/src/requests/payloads/get_webhook_info.rs b/src/requests/payloads/get_webhook_info.rs index f3a1a124..33653301 100644 --- a/src/requests/payloads/get_webhook_info.rs +++ b/src/requests/payloads/get_webhook_info.rs @@ -1,7 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, + types::WebhookInfo, }; -use crate::types::WebhookInfo; /// Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty. #[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize, Default)] diff --git a/src/requests/payloads/kick_chat_member.rs b/src/requests/payloads/kick_chat_member.rs index 5c51b910..741e4e52 100644 --- a/src/requests/payloads/kick_chat_member.rs +++ b/src/requests/payloads/kick_chat_member.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/leave_chat.rs b/src/requests/payloads/leave_chat.rs index dfd2549e..88651193 100644 --- a/src/requests/payloads/leave_chat.rs +++ b/src/requests/payloads/leave_chat.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/pin_chat_message.rs b/src/requests/payloads/pin_chat_message.rs index 50116da6..b3cc9736 100644 --- a/src/requests/payloads/pin_chat_message.rs +++ b/src/requests/payloads/pin_chat_message.rs @@ -1,7 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, + types::{ChatId, True}, }; -use crate::types::{ChatId, True}; /// Use this method to pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/promote_chat_member.rs b/src/requests/payloads/promote_chat_member.rs index 8cbb707f..2e70cc3e 100644 --- a/src/requests/payloads/promote_chat_member.rs +++ b/src/requests/payloads/promote_chat_member.rs @@ -1,7 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, + types::{ChatId, True}, }; -use crate::types::{ChatId, True}; /// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/restrict_chat_member.rs b/src/requests/payloads/restrict_chat_member.rs index 62044448..8fdba379 100644 --- a/src/requests/payloads/restrict_chat_member.rs +++ b/src/requests/payloads/restrict_chat_member.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ChatPermissions, True}, diff --git a/src/requests/payloads/send_animation.rs b/src/requests/payloads/send_animation.rs index 9bc35764..c48fe4bb 100644 --- a/src/requests/payloads/send_animation.rs +++ b/src/requests/payloads/send_animation.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_audio.rs b/src/requests/payloads/send_audio.rs index 9291c9d2..d99461d1 100644 --- a/src/requests/payloads/send_audio.rs +++ b/src/requests/payloads/send_audio.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_chat_action.rs b/src/requests/payloads/send_chat_action.rs index 3f38a842..2088714d 100644 --- a/src/requests/payloads/send_chat_action.rs +++ b/src/requests/payloads/send_chat_action.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/send_contact.rs b/src/requests/payloads/send_contact.rs index e3d9e84f..63ed0884 100644 --- a/src/requests/payloads/send_contact.rs +++ b/src/requests/payloads/send_contact.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ReplyMarkup, Message}, diff --git a/src/requests/payloads/send_document.rs b/src/requests/payloads/send_document.rs index c0eedd66..d81d821b 100644 --- a/src/requests/payloads/send_document.rs +++ b/src/requests/payloads/send_document.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_game.rs b/src/requests/payloads/send_game.rs index 1faa13a5..1a4ef7e4 100644 --- a/src/requests/payloads/send_game.rs +++ b/src/requests/payloads/send_game.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/send_invoice.rs b/src/requests/payloads/send_invoice.rs index ff30e6ae..5e361394 100644 --- a/src/requests/payloads/send_invoice.rs +++ b/src/requests/payloads/send_invoice.rs @@ -1,7 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, + types::{LabeledPrice, InlineKeyboardMarkup, Message}, }; -use crate::types::{LabeledPrice, InlineKeyboardMarkup, Message}; /// Use this method to send invoices. On success, the sent Message is returned. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/send_location.rs b/src/requests/payloads/send_location.rs index 07f2d54b..238c707d 100644 --- a/src/requests/payloads/send_location.rs +++ b/src/requests/payloads/send_location.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ReplyMarkup, Message}, diff --git a/src/requests/payloads/send_media_group.rs b/src/requests/payloads/send_media_group.rs index 740a148b..730cd60c 100644 --- a/src/requests/payloads/send_media_group.rs +++ b/src/requests/payloads/send_media_group.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_message.rs b/src/requests/payloads/send_message.rs index e9c247ee..194b94fe 100644 --- a/src/requests/payloads/send_message.rs +++ b/src/requests/payloads/send_message.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, Message, ParseMode, ReplyMarkup}, diff --git a/src/requests/payloads/send_photo.rs b/src/requests/payloads/send_photo.rs index 167b85e1..8abb1994 100644 --- a/src/requests/payloads/send_photo.rs +++ b/src/requests/payloads/send_photo.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_poll.rs b/src/requests/payloads/send_poll.rs index ae20e48e..c4ba84a6 100644 --- a/src/requests/payloads/send_poll.rs +++ b/src/requests/payloads/send_poll.rs @@ -1,7 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, + types::{ChatId, ReplyMarkup, Message}, }; -use crate::types::{ChatId, ReplyMarkup, Message}; /// Use this method to send a native poll. A native poll can't be sent to a private chat. On success, the sent Message is returned. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/send_sticker.rs b/src/requests/payloads/send_sticker.rs index 7f41e4d1..c27fcd41 100644 --- a/src/requests/payloads/send_sticker.rs +++ b/src/requests/payloads/send_sticker.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_venue.rs b/src/requests/payloads/send_venue.rs index ae5565fc..3b8e06d5 100644 --- a/src/requests/payloads/send_venue.rs +++ b/src/requests/payloads/send_venue.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ReplyMarkup, Message}, diff --git a/src/requests/payloads/send_video.rs b/src/requests/payloads/send_video.rs index 42dd0a07..877f5afe 100644 --- a/src/requests/payloads/send_video.rs +++ b/src/requests/payloads/send_video.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_video_note.rs b/src/requests/payloads/send_video_note.rs index 83489642..e05719c9 100644 --- a/src/requests/payloads/send_video_note.rs +++ b/src/requests/payloads/send_video_note.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/send_voice.rs b/src/requests/payloads/send_voice.rs index 747c8439..c72a9be2 100644 --- a/src/requests/payloads/send_voice.rs +++ b/src/requests/payloads/send_voice.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use reqwest::multipart::Form; use crate::{ diff --git a/src/requests/payloads/set_chat_description.rs b/src/requests/payloads/set_chat_description.rs index 53d69615..615592be 100644 --- a/src/requests/payloads/set_chat_description.rs +++ b/src/requests/payloads/set_chat_description.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/set_chat_permissions.rs b/src/requests/payloads/set_chat_permissions.rs index f3cdb91c..e2e79e9a 100644 --- a/src/requests/payloads/set_chat_permissions.rs +++ b/src/requests/payloads/set_chat_permissions.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, ChatPermissions, True}, diff --git a/src/requests/payloads/set_chat_photo.rs b/src/requests/payloads/set_chat_photo.rs index bb7fe687..5cd98587 100644 --- a/src/requests/payloads/set_chat_photo.rs +++ b/src/requests/payloads/set_chat_photo.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, InputFile, True}, diff --git a/src/requests/payloads/set_chat_sticker_set.rs b/src/requests/payloads/set_chat_sticker_set.rs index c9aa8284..fd8cca2c 100644 --- a/src/requests/payloads/set_chat_sticker_set.rs +++ b/src/requests/payloads/set_chat_sticker_set.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/set_chat_title.rs b/src/requests/payloads/set_chat_title.rs index adea9de5..0bd92f9b 100644 --- a/src/requests/payloads/set_chat_title.rs +++ b/src/requests/payloads/set_chat_title.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/set_game_score.rs b/src/requests/payloads/set_game_score.rs index d8ed3f8d..eea7281f 100644 --- a/src/requests/payloads/set_game_score.rs +++ b/src/requests/payloads/set_game_score.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{Message, ChatId}, diff --git a/src/requests/payloads/set_game_score_inline.rs b/src/requests/payloads/set_game_score_inline.rs index 09ebb9fd..04602a8e 100644 --- a/src/requests/payloads/set_game_score_inline.rs +++ b/src/requests/payloads/set_game_score_inline.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, diff --git a/src/requests/payloads/set_sticker_position_in_set.rs b/src/requests/payloads/set_sticker_position_in_set.rs index 17914bf9..d42ea1a4 100644 --- a/src/requests/payloads/set_sticker_position_in_set.rs +++ b/src/requests/payloads/set_sticker_position_in_set.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::True, diff --git a/src/requests/payloads/set_webhook.rs b/src/requests/payloads/set_webhook.rs index c377ccf2..7c2aaf6a 100644 --- a/src/requests/payloads/set_webhook.rs +++ b/src/requests/payloads/set_webhook.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{InputFile, True}, diff --git a/src/requests/payloads/stop_message_live_location.rs b/src/requests/payloads/stop_message_live_location.rs index c30d5b07..b6551fe5 100644 --- a/src/requests/payloads/stop_message_live_location.rs +++ b/src/requests/payloads/stop_message_live_location.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, InlineKeyboardMarkup, Message}, diff --git a/src/requests/payloads/stop_message_live_location_inline.rs b/src/requests/payloads/stop_message_live_location_inline.rs index 01c630cb..70b54cb2 100644 --- a/src/requests/payloads/stop_message_live_location_inline.rs +++ b/src/requests/payloads/stop_message_live_location_inline.rs @@ -1,4 +1,4 @@ - +use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, diff --git a/src/requests/payloads/stop_poll.rs b/src/requests/payloads/stop_poll.rs index 76760039..6fc75bfc 100644 --- a/src/requests/payloads/stop_poll.rs +++ b/src/requests/payloads/stop_poll.rs @@ -1,8 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, - types::{ChatId, InlineKeyboardMarkup}, + types::{ChatId, InlineKeyboardMarkup, Poll}, }; -use crate::types::Poll; /// Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned. #[serde_with_macros::skip_serializing_none] diff --git a/src/requests/payloads/unban_chat_member.rs b/src/requests/payloads/unban_chat_member.rs index 054d66c8..bc176ecc 100644 --- a/src/requests/payloads/unban_chat_member.rs +++ b/src/requests/payloads/unban_chat_member.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/unpin_chat_message.rs b/src/requests/payloads/unpin_chat_message.rs index 58ac16d7..a03a9d96 100644 --- a/src/requests/payloads/unpin_chat_message.rs +++ b/src/requests/payloads/unpin_chat_message.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{ChatId, True}, diff --git a/src/requests/payloads/upload_sticker_file.rs b/src/requests/payloads/upload_sticker_file.rs index 6d0af61c..13996cba 100644 --- a/src/requests/payloads/upload_sticker_file.rs +++ b/src/requests/payloads/upload_sticker_file.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ requests::{dynamic, json, Method}, types::{InputFile, File}, diff --git a/src/types/animation.rs b/src/types/animation.rs index 435f8c45..9920f0fd 100644 --- a/src/types/animation.rs +++ b/src/types/animation.rs @@ -1,9 +1,12 @@ +use serde::{Deserialize, Serialize}; + use crate::types::PhotoSize; /// This object represents an animation file (GIF or H.264/MPEG-4 AVC video /// without sound). /// /// [The official docs](https://core.telegram.org/bots/api#animation). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Animation { /// An identifier for this file. diff --git a/src/types/audio.rs b/src/types/audio.rs index 7d5dcb46..9b2b2567 100644 --- a/src/types/audio.rs +++ b/src/types/audio.rs @@ -1,9 +1,12 @@ +use serde::{Deserialize, Serialize}; + use crate::types::PhotoSize; /// This object represents an audio file to be treated as music by the Telegram /// clients. /// /// [The official docs](https://core.telegram.org/bots/api#audio). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Audio { /// An identifier for this file. diff --git a/src/types/callback_game.rs b/src/types/callback_game.rs index 8a86421b..b3497ff2 100644 --- a/src/types/callback_game.rs +++ b/src/types/callback_game.rs @@ -1,4 +1,5 @@ /// 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). +// TODO: derives? pub struct CallbackGame; diff --git a/src/types/callback_query.rs b/src/types/callback_query.rs index 10b1a126..2aed9fec 100644 --- a/src/types/callback_query.rs +++ b/src/types/callback_query.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{Message, User}; /// This object represents an incoming callback query from a callback button in @@ -11,6 +13,7 @@ use crate::types::{Message, User}; /// /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [inline mode]: https://core.telegram.org/bots/api#inline-mode +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct CallbackQuery { /// An unique identifier for this query. diff --git a/src/types/chat.rs b/src/types/chat.rs index 82b4c3fb..2df5dda7 100644 --- a/src/types/chat.rs +++ b/src/types/chat.rs @@ -1,8 +1,11 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{ChatPermissions, ChatPhoto, Message}; /// This object represents a chat. /// /// [The official docs](https://core.telegram.org/bots/api#chat). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Chat { /// A unique identifier for this chat. This number may be greater than 32 @@ -21,6 +24,7 @@ pub struct Chat { pub photo: Option, } +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(untagged)] pub enum ChatKind { @@ -74,6 +78,7 @@ pub enum ChatKind { }, } +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[serde(rename_all = "snake_case")] #[serde(tag = "type")] diff --git a/src/types/chat_action.rs b/src/types/chat_action.rs index 77493edd..730df5c6 100644 --- a/src/types/chat_action.rs +++ b/src/types/chat_action.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[serde(rename_all = "snake_case")] pub enum ChatAction { diff --git a/src/types/chat_id.rs b/src/types/chat_id.rs index 73e95942..5b8c03b9 100644 --- a/src/types/chat_id.rs +++ b/src/types/chat_id.rs @@ -1,3 +1,6 @@ +use derive_more::{Display, From}; +use serde::{Deserialize, Serialize}; + /// A unique identifier for the target chat or username of the target channel /// (in the format `@channelusername`). #[derive( diff --git a/src/types/chat_member.rs b/src/types/chat_member.rs index f13c4f37..71c24c09 100644 --- a/src/types/chat_member.rs +++ b/src/types/chat_member.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::User; /// This object contains information about one member of the chat. diff --git a/src/types/chat_permissions.rs b/src/types/chat_permissions.rs index 0542cec0..2c494db7 100644 --- a/src/types/chat_permissions.rs +++ b/src/types/chat_permissions.rs @@ -1,46 +1,41 @@ +use serde::{Deserialize, Serialize}; + /// Describes actions that a non-administrator user is allowed to take in a /// chat. /// /// [The official docs](https://core.telegram.org/bots/api#chatpermissions). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct ChatPermissions { /// `true`, if the user is allowed to send text messages, contacts, /// locations and venues. - #[serde(skip_serializing_if = "Option::is_none")] pub can_send_messages: Option, /// `true`, if the user is allowed to send audios, documents, /// photos, videos, video notes and voice notes, implies /// `can_send_messages`. - #[serde(skip_serializing_if = "Option::is_none")] pub can_send_media_messages: Option, /// `true`, if the user is allowed to send polls, implies /// `can_send_messages`. - #[serde(skip_serializing_if = "Option::is_none")] pub can_send_polls: Option, /// `true`, if the user is allowed to send animations, games, stickers and /// use inline bots, implies `can_send_media_messages`. - #[serde(skip_serializing_if = "Option::is_none")] pub can_send_other_messages: Option, /// `true`, if the user is allowed to add web page previews to /// their messages, implies `can_send_media_messages`. - #[serde(skip_serializing_if = "Option::is_none")] pub can_add_web_page_previews: Option, /// `true`, if the user is allowed to change the chat title, photo and /// other settings. Ignored in public supergroups. - #[serde(skip_serializing_if = "Option::is_none")] pub can_change_info: Option, /// `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, /// `true`, if the user is allowed to pin messages. Ignored in public /// supergroups. - #[serde(skip_serializing_if = "Option::is_none")] pub can_pin_messages: Option, } diff --git a/src/types/chat_photo.rs b/src/types/chat_photo.rs index 5c0a7d36..f7e5a9ec 100644 --- a/src/types/chat_photo.rs +++ b/src/types/chat_photo.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a chat photo. /// /// [The official docs](https://core.telegram.org/bots/api#chatphoto). diff --git a/src/types/chosen_inline_result.rs b/src/types/chosen_inline_result.rs index 16ced5f5..1254bb3f 100644 --- a/src/types/chosen_inline_result.rs +++ b/src/types/chosen_inline_result.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{Location, User}; /// Represents a [result] of an inline query that was chosen by the user and @@ -6,6 +8,7 @@ use crate::types::{Location, User}; /// [The official docs](https://core.telegram.org/bots/api#choseninlineresult). /// /// [result]: https://core.telegram.org/bots/api#inlinequeryresult +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct ChosenInlineResult { /// The unique identifier for the result that was chosen. diff --git a/src/types/contact.rs b/src/types/contact.rs index 7aaddd18..43e8f04e 100644 --- a/src/types/contact.rs +++ b/src/types/contact.rs @@ -1,6 +1,9 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a phone 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)] pub struct Contact { /// A contact's phone number. diff --git a/src/types/document.rs b/src/types/document.rs index 0a741614..f51701fa 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::PhotoSize; /// This object represents a general file (as opposed to [photos], [voice @@ -8,6 +10,7 @@ use crate::types::PhotoSize; /// [photos]: https://core.telegram.org/bots/api#photosize /// [voice messages]: https://core.telegram.org/bots/api#voice /// [audio files]: https://core.telegram.org/bots/api#audio +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Document { /// An identifier for this file. diff --git a/src/types/encrypted_credentials.rs b/src/types/encrypted_credentials.rs index 19374388..4b3efdce 100644 --- a/src/types/encrypted_credentials.rs +++ b/src/types/encrypted_credentials.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// Contains data required for decrypting and authenticating /// [`EncryptedPassportElement`]. See the [Telegram Passport Documentation] for /// a complete description of the data decryption and authentication processes. @@ -7,6 +9,7 @@ /// [`EncryptedPassportElement`]: /// crate::types::EncryptedPassportElement /// [Telegram Passport Documentation]: https://core.telegram.org/passport#receiving-information +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct EncryptedCredentials { /// Base64-encoded encrypted JSON-serialized data with unique user's diff --git a/src/types/encrypted_passport_element.rs b/src/types/encrypted_passport_element.rs index c83ed40b..4e99494b 100644 --- a/src/types/encrypted_passport_element.rs +++ b/src/types/encrypted_passport_element.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use super::PassportFile; /// Contains information about documents or other Telegram Passport elements @@ -17,6 +19,7 @@ pub struct EncryptedPassportElement { pub kind: EncryptedPassportElementKind, } +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[serde(rename_all = "snake_case")] pub enum EncryptedPassportElementKind { diff --git a/src/types/file.rs b/src/types/file.rs index 3dfa26e1..30851263 100644 --- a/src/types/file.rs +++ b/src/types/file.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a file ready to be downloaded. The file can be /// downloaded via the link `https://api.telegram.org/file/bot/`. /// It is guaranteed that the link will be valid for at least 1 hour. When the @@ -14,6 +16,7 @@ pub struct File { /// File size, if known. pub file_size: u32, + // TODO: chacge "Use ..." to use bot.download... /// File path. Use `https://api.telegram.org/file/bot/` /// to get the file. pub file_path: String, diff --git a/src/types/force_reply.rs b/src/types/force_reply.rs index 38e17453..36fe6d1d 100644 --- a/src/types/force_reply.rs +++ b/src/types/force_reply.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::True; /// Upon receiving a message with this object, Telegram clients will display a @@ -9,6 +11,7 @@ use crate::types::True; /// [The official docs](https://core.telegram.org/bots/api#forcereply). /// /// [privacy mode]: https://core.telegram.org/bots#privacy-mode +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct ForceReply { /// Shows reply interface to the user, as if they manually selected the @@ -21,6 +24,5 @@ pub struct ForceReply { /// (has reply_to_message_id), sender of the original message. /// /// [`Message`]: crate::types::Message - #[serde(skip_serializing_if = "Option::is_none")] pub selective: Option, } diff --git a/src/types/game.rs b/src/types/game.rs index b056b7f7..e6214726 100644 --- a/src/types/game.rs +++ b/src/types/game.rs @@ -1,4 +1,4 @@ -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use crate::types::{Animation, MessageEntity, PhotoSize}; @@ -6,6 +6,7 @@ use crate::types::{Animation, MessageEntity, PhotoSize}; /// their short names will act as unique identifiers. /// /// [@Botfather]: https://t.me/botfather +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Game { /// Title of the game. diff --git a/src/types/game_high_score.rs b/src/types/game_high_score.rs index 23a30f3e..c99d6cf9 100644 --- a/src/types/game_high_score.rs +++ b/src/types/game_high_score.rs @@ -1,4 +1,4 @@ -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use crate::types::user::User; diff --git a/src/types/inline_keyboard_button.rs b/src/types/inline_keyboard_button.rs index f1046372..6ad53ad0 100644 --- a/src/types/inline_keyboard_button.rs +++ b/src/types/inline_keyboard_button.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents one button of an inline keyboard. /// /// [The official docs](https://core.telegram.org/bots/api#inlinekeyboardbutton). diff --git a/src/types/inline_keyboard_markup.rs b/src/types/inline_keyboard_markup.rs index 964c0c89..3aff467c 100644 --- a/src/types/inline_keyboard_markup.rs +++ b/src/types/inline_keyboard_markup.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::InlineKeyboardButton; /// This object represents an [inline keyboard] that appears right next to the diff --git a/src/types/inline_query.rs b/src/types/inline_query.rs index c0e5d1ca..0478cc0c 100644 --- a/src/types/inline_query.rs +++ b/src/types/inline_query.rs @@ -1,9 +1,12 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{Location, User}; /// This object represents an incoming inline query. When the user sends an /// empty query, your bot could return some default or trending results. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequery). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQuery { /// Unique identifier for this query. diff --git a/src/types/inline_query_result.rs b/src/types/inline_query_result.rs index 7a481205..c1c63c6c 100644 --- a/src/types/inline_query_result.rs +++ b/src/types/inline_query_result.rs @@ -1,5 +1,8 @@ #![allow(clippy::large_enum_variant)] +use derive_more::From; +use serde::{Deserialize, Serialize}; + use crate::types::{ InlineQueryResultArticle, InlineQueryResultAudio, InlineQueryResultCachedAudio, InlineQueryResultCachedDocument, diff --git a/src/types/inline_query_result_article.rs b/src/types/inline_query_result_article.rs index 26bca3eb..e4913b7a 100644 --- a/src/types/inline_query_result_article.rs +++ b/src/types/inline_query_result_article.rs @@ -1,8 +1,11 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// Represents a link to an article or web page. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultarticle). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultArticle { /// Unique identifier for this result, 1-64 Bytes. @@ -15,31 +18,24 @@ pub struct InlineQueryResultArticle { pub input_message_content: InputMessageContent, /// Inline keyboard attached to the message. - #[serde(skip_serializing_if = "Option::is_none")] pub reply_markup: Option, /// URL of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub url: Option, /// Pass `true`, if you don't want the URL to be shown in the /// message. - #[serde(skip_serializing_if = "Option::is_none")] pub hide_url: Option, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Url of the thumbnail for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_url: Option, /// Thumbnail width. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_width: Option, /// Thumbnail height. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, } diff --git a/src/types/inline_query_result_audio.rs b/src/types/inline_query_result_audio.rs index 9d457a32..e8770830 100644 --- a/src/types/inline_query_result_audio.rs +++ b/src/types/inline_query_result_audio.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to an MP3 audio file. By default, this audio file will be @@ -5,6 +7,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// a message with the specified content instead of the audio. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultaudio). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultAudio { /// Unique identifier for this result, 1-64 bytes. @@ -17,7 +20,6 @@ pub struct InlineQueryResultAudio { pub title: String, /// Caption, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -26,24 +28,19 @@ pub struct InlineQueryResultAudio { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// Performer. - #[serde(skip_serializing_if = "Option::is_none")] pub performer: Option, /// Audio duration in seconds. - #[serde(skip_serializing_if = "Option::is_none")] pub audio_duration: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the audio. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_audio.rs b/src/types/inline_query_result_cached_audio.rs index 54bfe1b0..4deca99a 100644 --- a/src/types/inline_query_result_cached_audio.rs +++ b/src/types/inline_query_result_cached_audio.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to an MP3 audio file stored on the Telegram servers. By @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// instead of the audio. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedaudio). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedAudio { /// Unique identifier for this result, 1-64 bytes. @@ -15,7 +18,6 @@ pub struct InlineQueryResultCachedAudio { pub audio_file_id: String, /// Caption, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -24,16 +26,13 @@ pub struct InlineQueryResultCachedAudio { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the audio. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_document.rs b/src/types/inline_query_result_cached_document.rs index 8ca938fd..4255e964 100644 --- a/src/types/inline_query_result_cached_document.rs +++ b/src/types/inline_query_result_cached_document.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a file stored on the Telegram servers. By default, this @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// instead of the file. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcacheddocument). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedDocument { /// Unique identifier for this result, 1-64 bytes. @@ -18,11 +21,9 @@ pub struct InlineQueryResultCachedDocument { pub document_file_id: String, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Caption of the document to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -31,16 +32,13 @@ pub struct InlineQueryResultCachedDocument { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the file. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_gif.rs b/src/types/inline_query_result_cached_gif.rs index 9bd97b06..b949208c 100644 --- a/src/types/inline_query_result_cached_gif.rs +++ b/src/types/inline_query_result_cached_gif.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to an animated GIF file stored on the Telegram servers. By @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// message with specified content instead of the animation. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedgif). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedGif { /// Unique identifier for this result, 1-64 bytes. @@ -15,11 +18,9 @@ pub struct InlineQueryResultCachedGif { pub gif_file_id: String, /// Title for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, /// Caption of the GIF file to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [`ParseMode::Markdown`] or [`ParseMode::HTML`], if you want @@ -29,16 +30,13 @@ pub struct InlineQueryResultCachedGif { /// [`ParseMode::Markdown`]: crate::types::ParseMode::Markdown /// [`ParseMode::HTML`]: crate::types::ParseMode::HTML /// [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, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the GIF animation. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_mpeg4_gif.rs b/src/types/inline_query_result_cached_mpeg4_gif.rs index b0c1e669..de7ed656 100644 --- a/src/types/inline_query_result_cached_mpeg4_gif.rs +++ b/src/types/inline_query_result_cached_mpeg4_gif.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a video animation (H.264/MPEG-4 AVC video without @@ -7,6 +9,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// instead of the animation. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedMpeg4Gif { /// Unique identifier for this result, 1-64 bytes. @@ -16,11 +19,9 @@ pub struct InlineQueryResultCachedMpeg4Gif { pub mpeg4_file_id: String, /// Title for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, /// Caption of the MPEG-4 file to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -29,16 +30,13 @@ pub struct InlineQueryResultCachedMpeg4Gif { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the video animation. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_photo.rs b/src/types/inline_query_result_cached_photo.rs index 23e2830a..c1c35ff8 100644 --- a/src/types/inline_query_result_cached_photo.rs +++ b/src/types/inline_query_result_cached_photo.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a photo stored on the Telegram servers. By default, @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// content instead of the photo. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedphoto). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedPhoto { /// Unique identifier for this result, 1-64 bytes. @@ -15,15 +18,12 @@ pub struct InlineQueryResultCachedPhoto { pub photo_file_id: String, /// Title for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Caption of the photo to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -32,16 +32,13 @@ pub struct InlineQueryResultCachedPhoto { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the photo. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_sticker.rs b/src/types/inline_query_result_cached_sticker.rs index 4024b323..32dd6f8e 100644 --- a/src/types/inline_query_result_cached_sticker.rs +++ b/src/types/inline_query_result_cached_sticker.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// Represents a link to a sticker stored on the Telegram servers. By default, @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// of the sticker. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedsticker). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedSticker { /// Unique identifier for this result, 1-64 bytes. @@ -17,10 +20,8 @@ pub struct InlineQueryResultCachedSticker { /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the sticker. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_video.rs b/src/types/inline_query_result_cached_video.rs index 65922091..29068d49 100644 --- a/src/types/inline_query_result_cached_video.rs +++ b/src/types/inline_query_result_cached_video.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a video file stored on the Telegram servers. By @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// the specified content instead of the video. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedVideo { /// Unique identifier for this result, 1-64 bytes. @@ -18,11 +21,9 @@ pub struct InlineQueryResultCachedVideo { pub title: String, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Caption of the video to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -31,16 +32,13 @@ pub struct InlineQueryResultCachedVideo { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the video. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_cached_voice.rs b/src/types/inline_query_result_cached_voice.rs index 2b527002..eedd4aab 100644 --- a/src/types/inline_query_result_cached_voice.rs +++ b/src/types/inline_query_result_cached_voice.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a voice message stored on the Telegram servers. By @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// instead of the voice message. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultCachedVoice { /// Unique identifier for this result, 1-64 bytes. @@ -18,7 +21,6 @@ pub struct InlineQueryResultCachedVoice { pub title: String, /// Caption, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -27,16 +29,13 @@ pub struct InlineQueryResultCachedVoice { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the voice message. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_contact.rs b/src/types/inline_query_result_contact.rs index c016eeca..b1d0e7cd 100644 --- a/src/types/inline_query_result_contact.rs +++ b/src/types/inline_query_result_contact.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// Represents a contact with a phone number. By default, this contact will be @@ -5,6 +7,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// a message with the specified content instead of the contact. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultContact { /// Unique identifier for this result, 1-64 Bytes. @@ -17,35 +20,28 @@ pub struct InlineQueryResultContact { pub first_name: String, /// Contact's last name. - #[serde(skip_serializing_if = "Option::is_none")] pub last_name: Option, /// Additional data about the contact in the form of a [vCard], 0-2048 /// bytes. /// /// [VCard]: https://en.wikipedia.org/wiki/VCard - #[serde(skip_serializing_if = "Option::is_none")] pub vcard: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the contact. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, /// Url of the thumbnail for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_url: Option, /// Thumbnail width. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_width: Option, /// Thumbnail height. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, } diff --git a/src/types/inline_query_result_document.rs b/src/types/inline_query_result_document.rs index 68a4aa61..f17065b8 100644 --- a/src/types/inline_query_result_document.rs +++ b/src/types/inline_query_result_document.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a file. By default, this file will be sent by the user @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// only **.PDF** and **.ZIP** files can be sent using this method. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultdocument). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultDocument { /// Unique identifier for this result, 1-64 bytes. @@ -15,7 +18,6 @@ pub struct InlineQueryResultDocument { pub title: String, /// Caption of the document to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -24,7 +26,6 @@ pub struct InlineQueryResultDocument { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// A valid URL for the file. @@ -35,26 +36,20 @@ pub struct InlineQueryResultDocument { pub mime_type: String, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Inline keyboard attached to the message. - #[serde(skip_serializing_if = "Option::is_none")] pub reply_markup: Option, /// Content of the message to be sent instead of the file. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, /// URL of the thumbnail (jpeg only) for the file. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_url: Option, /// Thumbnail width. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_width: Option, /// Thumbnail height. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, } diff --git a/src/types/inline_query_result_game.rs b/src/types/inline_query_result_game.rs index e64d16fa..93cb27a3 100644 --- a/src/types/inline_query_result_game.rs +++ b/src/types/inline_query_result_game.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::InlineKeyboardMarkup; /// Represents a [game]. @@ -5,6 +7,7 @@ use crate::types::InlineKeyboardMarkup; /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgame). /// /// [game]: https://core.telegram.org/bots/api#games +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct InlineQueryResultGame { /// Unique identifier for this result, 1-64 bytes. @@ -16,6 +19,5 @@ pub struct InlineQueryResultGame { /// [Inline keyboard] attached to the message. /// /// [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, } diff --git a/src/types/inline_query_result_gif.rs b/src/types/inline_query_result_gif.rs index aa96b940..b96e4f58 100644 --- a/src/types/inline_query_result_gif.rs +++ b/src/types/inline_query_result_gif.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to an animated GIF file. By default, this animated GIF @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// instead of the animation. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgif). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultGif { /// Unique identifier for this result, 1-64 bytes. @@ -15,26 +18,21 @@ pub struct InlineQueryResultGif { pub gif_url: String, /// Width of the GIF. - #[serde(skip_serializing_if = "Option::is_none")] pub gif_width: Option, /// Height of the GIFv. - #[serde(skip_serializing_if = "Option::is_none")] pub gif_height: Option, /// Duration of the GIF. - #[serde(skip_serializing_if = "Option::is_none")] pub gif_duration: Option, /// URL of the static thumbnail for the result (jpeg or gif). pub thumb_url: String, /// Title for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, /// Caption of the GIF file to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -43,16 +41,13 @@ pub struct InlineQueryResultGif { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the GIF animation. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_location.rs b/src/types/inline_query_result_location.rs index 79c39dc9..c40d01e8 100644 --- a/src/types/inline_query_result_location.rs +++ b/src/types/inline_query_result_location.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// Represents a location on a map. By default, the location will be sent by the @@ -5,6 +7,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// with the specified content instead of the location. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultlocation). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultLocation { /// Unique identifier for this result, 1-64 Bytes. @@ -21,28 +24,22 @@ pub struct InlineQueryResultLocation { /// Period in seconds for which the location can be updated, should be /// between 60 and 86400. - #[serde(skip_serializing_if = "Option::is_none")] pub live_period: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the location. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, /// Url of the thumbnail for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_url: Option, /// Thumbnail width. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_width: Option, /// Thumbnail height. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, } diff --git a/src/types/inline_query_result_mpeg4_gif.rs b/src/types/inline_query_result_mpeg4_gif.rs index ccc48b6e..ea59f65c 100644 --- a/src/types/inline_query_result_mpeg4_gif.rs +++ b/src/types/inline_query_result_mpeg4_gif.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a video animation (H.264/MPEG-4 AVC video without @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// a message with the specified content instead of the animation. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultMpeg4Gif { /// Unique identifier for this result, 1-64 bytes. @@ -15,26 +18,21 @@ pub struct InlineQueryResultMpeg4Gif { pub mpeg4_url: String, /// Video width. - #[serde(skip_serializing_if = "Option::is_none")] pub mpeg4_width: Option, /// Video height. - #[serde(skip_serializing_if = "Option::is_none")] pub mpeg4_height: Option, /// Video duration. - #[serde(skip_serializing_if = "Option::is_none")] pub mpeg4_duration: Option, /// URL of the static thumbnail (jpeg or gif) for the result. pub thumb_url: String, /// Title for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, /// Caption of the MPEG-4 file to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -43,16 +41,13 @@ pub struct InlineQueryResultMpeg4Gif { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the video animation. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_photo.rs b/src/types/inline_query_result_photo.rs index df8f0e0b..0a0b5c0a 100644 --- a/src/types/inline_query_result_photo.rs +++ b/src/types/inline_query_result_photo.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a photo. By default, this photo will be sent by the @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// of the photo. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultphoto). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultPhoto { /// Unique identifier for this result, 1-64 bytes. @@ -19,23 +22,18 @@ pub struct InlineQueryResultPhoto { pub thumb_url: String, /// Width of the photo. - #[serde(skip_serializing_if = "Option::is_none")] pub photo_width: Option, /// Height of the photo. - #[serde(skip_serializing_if = "Option::is_none")] pub photo_height: Option, /// Title for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Caption of the photo to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -44,16 +42,13 @@ pub struct InlineQueryResultPhoto { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the photo. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_venue.rs b/src/types/inline_query_result_venue.rs index 982a6fe2..45131064 100644 --- a/src/types/inline_query_result_venue.rs +++ b/src/types/inline_query_result_venue.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// Represents a venue. By default, the venue will be sent by the user. @@ -5,6 +7,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent}; /// the specified content instead of the venue. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvenue). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultVenue { /// Unique identifier for this result, 1-64 Bytes. @@ -23,34 +26,27 @@ pub struct InlineQueryResultVenue { pub address: String, /// Foursquare identifier of the venue if known. - #[serde(skip_serializing_if = "Option::is_none")] pub foursquare_id: Option, /// Foursquare type of the venue, if known. (For example, /// `arts_entertainment/default`, `arts_entertainment/aquarium` or /// `food/icecream`.) - #[serde(skip_serializing_if = "Option::is_none")] pub foursquare_type: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the venue. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, /// Url of the thumbnail for the result. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_url: Option, /// Thumbnail width. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_width: Option, /// Thumbnail height. - #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, } diff --git a/src/types/inline_query_result_video.rs b/src/types/inline_query_result_video.rs index 1721f76d..bece12c5 100644 --- a/src/types/inline_query_result_video.rs +++ b/src/types/inline_query_result_video.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a page containing an embedded video player or a video @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// message with the specified content instead of the video. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvideo). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultVideo { /// Unique identifier for this result, 1-64 bytes. @@ -24,7 +27,6 @@ pub struct InlineQueryResultVideo { pub title: String, /// Caption of the video to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -33,29 +35,23 @@ pub struct InlineQueryResultVideo { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// Video width. - #[serde(skip_serializing_if = "Option::is_none")] pub video_width: Option, /// Video height. - #[serde(skip_serializing_if = "Option::is_none")] pub video_height: Option, /// Video duration in seconds. - #[serde(skip_serializing_if = "Option::is_none")] pub video_duration: Option, /// Short description of the result. - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the video. This field is @@ -64,6 +60,5 @@ pub struct InlineQueryResultVideo { /// /// [`InlineQueryResultVideo`]: /// crate::types::InlineQueryResultVideo - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/inline_query_result_voice.rs b/src/types/inline_query_result_voice.rs index fc2227c7..f5acf6e5 100644 --- a/src/types/inline_query_result_voice.rs +++ b/src/types/inline_query_result_voice.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// Represents a link to a voice recording in an .ogg container encoded with @@ -6,6 +8,7 @@ use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; /// the specified content instead of the the voice message. /// /// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvoice). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct InlineQueryResultVoice { /// Unique identifier for this result, 1-64 bytes. @@ -18,7 +21,6 @@ pub struct InlineQueryResultVoice { pub title: String, /// Caption, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -27,20 +29,16 @@ pub struct InlineQueryResultVoice { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] pub parse_mode: Option, /// Recording duration in seconds. - #[serde(skip_serializing_if = "Option::is_none")] pub voice_duration: Option, /// [Inline keyboard] attached to the message. /// /// [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, /// Content of the message to be sent instead of the voice recording. - #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, } diff --git a/src/types/input_file.rs b/src/types/input_file.rs index 1476a934..8d70c0c7 100644 --- a/src/types/input_file.rs +++ b/src/types/input_file.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use std::path::PathBuf; /// This object represents the contents of a file to be uploaded. @@ -60,7 +62,7 @@ impl From for Option { } } -impl serde::Serialize for InputFile { +impl Serialize for InputFile { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, diff --git a/src/types/input_media.rs b/src/types/input_media.rs index dff0d954..bb622051 100644 --- a/src/types/input_media.rs +++ b/src/types/input_media.rs @@ -1,6 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{InputFile, ParseMode}; // TODO: should variants use new-type? +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[serde(tag = "type")] #[serde(rename_all = "snake_case")] @@ -16,7 +19,6 @@ pub enum InputMedia { media: InputFile, /// Caption of the photo to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -25,7 +27,6 @@ pub enum InputMedia { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, }, @@ -41,11 +42,9 @@ pub enum InputMedia { /// JPEG format and less than 200 kB in size. A thumbnail‘s width and /// height should not exceed 320. Ignored if the file is not uploaded /// using multipart/form-data. - #[serde(skip_serializing_if = "Option::is_none")] thumb: Option, /// Caption of the video to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -54,23 +53,18 @@ pub enum InputMedia { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, /// Video width. - #[serde(skip_serializing_if = "Option::is_none")] width: Option, /// Video height. - #[serde(skip_serializing_if = "Option::is_none")] height: Option, /// Video duration. - #[serde(skip_serializing_if = "Option::is_none")] duration: Option, /// Pass `true`, if the uploaded video is suitable for streaming. - #[serde(skip_serializing_if = "Option::is_none")] supports_streaming: Option, }, @@ -87,11 +81,9 @@ pub enum InputMedia { /// JPEG format and less than 200 kB in size. A thumbnail‘s width and /// height should not exceed 320. Ignored if the file is not uploaded /// using multipart/form-data. - #[serde(skip_serializing_if = "Option::is_none")] thumb: Option, /// Caption of the animation to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -100,19 +92,15 @@ pub enum InputMedia { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, /// Animation width. - #[serde(skip_serializing_if = "Option::is_none")] width: Option, /// Animation height. - #[serde(skip_serializing_if = "Option::is_none")] height: Option, /// Animation duration. - #[serde(skip_serializing_if = "Option::is_none")] duration: Option, }, @@ -128,11 +116,9 @@ pub enum InputMedia { /// JPEG format and less than 200 kB in size. A thumbnail‘s width and /// height should not exceed 320. Ignored if the file is not uploaded /// using multipart/form-data. - #[serde(skip_serializing_if = "Option::is_none")] thumb: Option, /// Caption of the audio to be sent, 0-1024 characters. - #[serde(skip_serializing_if = "Option::is_none")] caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -141,19 +127,15 @@ pub enum InputMedia { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, /// Duration of the audio in seconds. - #[serde(skip_serializing_if = "Option::is_none")] duration: Option, /// Performer of the audio. - #[serde(skip_serializing_if = "Option::is_none")] performer: Option, /// Title of the audio. - #[serde(skip_serializing_if = "Option::is_none")] title: Option, }, @@ -169,11 +151,9 @@ pub enum InputMedia { /// JPEG format and less than 200 kB in size. A thumbnail‘s width and /// height should not exceed 320. Ignored if the file is not uploaded /// using multipart/form-data. - #[serde(skip_serializing_if = "Option::is_none")] thumb: Option, /// Caption of the document to be sent, 0-1024 charactersю - #[serde(skip_serializing_if = "Option::is_none")] caption: Option, /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold, @@ -182,7 +162,6 @@ pub enum InputMedia { /// [Markdown]: https://core.telegram.org/bots/api#markdown-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 - #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, }, } diff --git a/src/types/input_message_content.rs b/src/types/input_message_content.rs index 1a9b231a..e3cbc26c 100644 --- a/src/types/input_message_content.rs +++ b/src/types/input_message_content.rs @@ -1,7 +1,8 @@ -use serde::Serialize; +use serde::{Deserialize, Serialize}; use crate::types::ParseMode; +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(untagged)] /// 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 /// [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 - #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, /// Disables link previews for links in the sent message. - #[serde(skip_serializing_if = "Option::is_none")] disable_web_page_preview: Option, }, @@ -40,7 +39,6 @@ pub enum InputMessageContent { /// Period in seconds for which the location can be updated, should be /// between 60 and 86400. - #[serde(skip_serializing_if = "Option::is_none")] live_period: Option, }, @@ -60,13 +58,11 @@ pub enum InputMessageContent { address: String, /// Foursquare identifier of the venue, if known. - #[serde(skip_serializing_if = "Option::is_none")] foursquare_id: Option, /// Foursquare type of the venue, if known. (For example, /// `arts_entertainment/default`, `arts_entertainment/aquarium` /// or `food/icecream`.) - #[serde(skip_serializing_if = "Option::is_none")] foursquare_type: Option, }, @@ -80,14 +76,12 @@ pub enum InputMessageContent { first_name: String, /// Contact's last name. - #[serde(skip_serializing_if = "Option::is_none")] last_name: Option, /// Additional data about the contact in the form of a [vCard], 0-2048 /// bytes. /// /// [vCard]: https://en.wikipedia.org/wiki/VCard - #[serde(skip_serializing_if = "Option::is_none")] vcard: Option, }, } diff --git a/src/types/invoice.rs b/src/types/invoice.rs index a4768e4c..ea402268 100644 --- a/src/types/invoice.rs +++ b/src/types/invoice.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object contains basic information about an invoice. /// /// [The official docs](https://core.telegram.org/bots/api#invoice). diff --git a/src/types/keyboard_button.rs b/src/types/keyboard_button.rs index 6efb2e98..522a917e 100644 --- a/src/types/keyboard_button.rs +++ b/src/types/keyboard_button.rs @@ -1,21 +1,143 @@ +use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; + +use crate::types::True; + /// This object represents one button of the reply keyboard. For filter text /// buttons String can be used instead of this object to specify text of the -/// button. Optional fields are mutually exclusive. +/// button. /// /// [The official docs](https://core.telegram.org/bots/api#keyboardbutton). -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +#[serde_with_macros::skip_serializing_none] +#[derive(Debug, Serialize, Deserialize, Hash, PartialEq, Eq, Clone)] pub struct KeyboardButton { /// Text of the button. If none of the optional fields are used, it will /// be sent as a message when the button is pressed. pub text: String, - /// If `true`, the user's phone number will be sent as a contact - /// when the button is pressed. Available in private chats only. - #[serde(skip_serializing_if = "Option::is_none")] - pub request_contact: Option, - - /// If `true`, the user's current location will be sent when the - /// button is pressed. Available in private chats only. - #[serde(skip_serializing_if = "Option::is_none")] - pub request_location: Option, + /// Request something from user. + /// - If `Some(Contact)`, the user's phone number will be sent as a contact + /// when the button is pressed. Available in private chats only + /// - If `Some(Location)`, the user's current location will be sent when + /// the button is pressed. Available in private chats only + #[serde(flatten)] + pub request: Option, +} + +// Serialize + Deserialize are implemented by hand +#[derive(Debug, Hash, PartialEq, Eq, Clone)] +pub enum ButtonRequest { + Location, + Contact, +} + +/// Helper struct for (de)serializing [`ButtonRequest`](ButtonRequest) +#[serde_with_macros::skip_serializing_none] +#[derive(Serialize, Deserialize)] +struct RawRequest { + /// Optional. If True, the user's phone number will be sent as a contact + /// when the button is pressed. Available in private chats only + #[serde(rename = "request_contact")] + contact: Option, + + /// Optional. If True, the user's current location will be sent when the + /// button is pressed. Available in private chats only + #[serde(rename = "request_location")] + location: Option, +} + +impl<'de> Deserialize<'de> for ButtonRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let raw = RawRequest::deserialize(deserializer)?; + match raw { + RawRequest { + contact: Some(_), + location: Some(_), + } => Err(D::Error::custom( + "`request_contact` and `request_location` fields are mutually \ + exclusive, but both were provided", + )), + RawRequest { + contact: Some(_), .. + } => Ok(Self::Contact), + RawRequest { + location: Some(_), .. + } => Ok(Self::Location), + _ => Err(D::Error::custom( + "Either one of `request_contact` and `request_location` \ + fields is required", + )), + } + } +} + +impl Serialize for ButtonRequest { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::Contact => RawRequest { + contact: Some(True), + location: None, + } + .serialize(serializer), + Self::Location => RawRequest { + contact: None, + location: Some(True), + } + .serialize(serializer), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn serialize_no_request() { + let button = KeyboardButton { + text: String::from(""), + request: None, + }; + let expected = r#"{"text":""}"#; + let actual = serde_json::to_string(&button).unwrap(); + assert_eq!(expected, actual); + } + + #[test] + fn serialize_request_contact() { + let button = KeyboardButton { + text: String::from(""), + request: Some(ButtonRequest::Contact), + }; + let expected = r#"{"text":"","request_contact":true}"#; + let actual = serde_json::to_string(&button).unwrap(); + assert_eq!(expected, actual); + } + + #[test] + fn deserialize_no_request() { + let json = r#"{"text":""}"#; + let expected = KeyboardButton { + text: String::from(""), + request: None, + }; + let actual = serde_json::from_str(json).unwrap(); + assert_eq!(expected, actual); + } + + #[test] + fn deserialize_request_contact() { + let json = r#"{"text":"","request_contact":true}"#; + let expected = KeyboardButton { + text: String::from(""), + request: Some(ButtonRequest::Contact), + }; + let actual = serde_json::from_str(json).unwrap(); + assert_eq!(expected, actual); + } } diff --git a/src/types/label_price.rs b/src/types/label_price.rs index 7774e440..22e3f9cd 100644 --- a/src/types/label_price.rs +++ b/src/types/label_price.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a portion of the price for goods or services. /// /// [The official docs](https://core.telegram.org/bots/api#labeledprice). diff --git a/src/types/location.rs b/src/types/location.rs index f1541be4..dbfafac5 100644 --- a/src/types/location.rs +++ b/src/types/location.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a point on the map. #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Location { diff --git a/src/types/login_url.rs b/src/types/login_url.rs index 9feec06d..380dc2d1 100644 --- a/src/types/login_url.rs +++ b/src/types/login_url.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a parameter of the inline keyboard button used to /// automatically authorize a user. Serves as a great replacement for the /// [Telegram Login Widget] when the user is coming from Telegram. All the user @@ -8,16 +10,11 @@ /// /// /// [Telegram Login Widget]: https://core.telegram.org/widgets/login +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct LoginUrl { pub url: String, - - #[serde(skip_serializing_if = "Option::is_none")] pub forward_text: Option, - - #[serde(skip_serializing_if = "Option::is_none")] pub bot_username: Option, - - #[serde(skip_serializing_if = "Option::is_none")] pub request_write_access: Option, } diff --git a/src/types/mask_position.rs b/src/types/mask_position.rs index 3d905ce2..88f83eb7 100644 --- a/src/types/mask_position.rs +++ b/src/types/mask_position.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object describes the position on faces where a mask should be placed by /// default. /// diff --git a/src/types/message.rs b/src/types/message.rs index 5020b4b8..439c0da0 100644 --- a/src/types/message.rs +++ b/src/types/message.rs @@ -1,5 +1,7 @@ #![allow(clippy::large_enum_variant)] +use serde::{Deserialize, Serialize}; + use crate::types::{ Animation, Audio, Chat, Contact, Document, Game, InlineKeyboardMarkup, Invoice, Location, MessageEntity, PassportData, PhotoSize, Poll, Sticker, @@ -25,6 +27,7 @@ pub struct Message { pub kind: MessageKind, } +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(untagged)] pub enum MessageKind { diff --git a/src/types/message_entity.rs b/src/types/message_entity.rs index 1e4dda7d..d6372a4c 100644 --- a/src/types/message_entity.rs +++ b/src/types/message_entity.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::User; /// This object represents one special entity in a text message. For example, diff --git a/src/types/order_info.rs b/src/types/order_info.rs index 3c56b1a5..7d7742f3 100644 --- a/src/types/order_info.rs +++ b/src/types/order_info.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::ShippingAddress; /// This object represents information about an order. diff --git a/src/types/passport_data.rs b/src/types/passport_data.rs index e05c98d2..c1416af3 100644 --- a/src/types/passport_data.rs +++ b/src/types/passport_data.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use super::{EncryptedCredentials, EncryptedPassportElement}; /// Contains information about Telegram Passport data shared with the bot by the diff --git a/src/types/passport_file.rs b/src/types/passport_file.rs index cfdddcaf..cc5228c7 100644 --- a/src/types/passport_file.rs +++ b/src/types/passport_file.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a file uploaded to Telegram Passport. Currently all /// Telegram Passport files are in JPEG format when decrypted and don't exceed /// 10MB. diff --git a/src/types/photo_size.rs b/src/types/photo_size.rs index 0c4d1be6..7d8c2f13 100644 --- a/src/types/photo_size.rs +++ b/src/types/photo_size.rs @@ -1,7 +1,10 @@ +use serde::{Deserialize, Serialize}; + /// This object represents one size of a photo or a [file]/[sticker] thumbnail. /// /// [file]: crate::types::Document /// [sticker]: crate::types::Sticker +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct PhotoSize { /// Identifier for this file. diff --git a/src/types/poll.rs b/src/types/poll.rs index e9f4138a..1cf82576 100644 --- a/src/types/poll.rs +++ b/src/types/poll.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object contains information about a poll. /// /// [The official docs](https://core.telegram.org/bots/api#poll). diff --git a/src/types/pre_checkout_query.rs b/src/types/pre_checkout_query.rs index 61bac96d..d08ffbd5 100644 --- a/src/types/pre_checkout_query.rs +++ b/src/types/pre_checkout_query.rs @@ -1,8 +1,11 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{OrderInfo, User}; /// This object contains information about an incoming pre-checkout query. /// /// [The official docs](https://core.telegram.org/bots/api#precheckoutquery). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct PreCheckoutQuery { /// Unique query identifier. diff --git a/src/types/reply_keyboard_markup.rs b/src/types/reply_keyboard_markup.rs index d7ac209c..e3757d71 100644 --- a/src/types/reply_keyboard_markup.rs +++ b/src/types/reply_keyboard_markup.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::KeyboardButton; /// This object represents a [custom keyboard] with reply options (see @@ -7,6 +9,7 @@ use crate::types::KeyboardButton; /// /// [custom keyboard]: 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)] pub struct ReplyKeyboardMarkup { /// Array of button rows, each represented by an Array of @@ -19,7 +22,6 @@ pub struct ReplyKeyboardMarkup { /// (e.g., make the keyboard smaller if there are just two rows of /// buttons). Defaults to `false`, in which case the custom keyboard is /// always of the same height as the app's standard keyboard. - #[serde(skip_serializing_if = "Option::is_none")] pub resize_keyboard: Option, /// Requests clients to hide the keyboard as soon as it's been used. The @@ -27,7 +29,6 @@ pub struct ReplyKeyboardMarkup { /// 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. /// Defaults to `false`. - #[serde(skip_serializing_if = "Option::is_none")] pub one_time_keyboard: Option, /// Use this parameter if you want to show the keyboard to specific users @@ -40,6 +41,5 @@ pub struct ReplyKeyboardMarkup { /// in the group don’t see the keyboard. /// /// [`Message`]: crate::types::Message - #[serde(skip_serializing_if = "Option::is_none")] pub selective: Option, } diff --git a/src/types/reply_keyboard_remove.rs b/src/types/reply_keyboard_remove.rs index 45ec1339..d34f2827 100644 --- a/src/types/reply_keyboard_remove.rs +++ b/src/types/reply_keyboard_remove.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::True; /// Upon receiving a message with this object, Telegram clients will remove the @@ -9,6 +11,7 @@ use crate::types::True; /// [The official docs](https://core.telegram.org/bots/api#replykeyboardremove). /// /// [`ReplyKeyboardMarkup`]: crate::types::ReplyKeyboardMarkup +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct ReplyKeyboardRemove { /// Requests clients to remove the custom keyboard (user will not be able @@ -29,6 +32,5 @@ pub struct ReplyKeyboardRemove { /// showing the keyboard with poll options to users who haven't voted yet. /// /// [`Message`]: crate::types::Message - #[serde(skip_serializing_if = "Option::is_none")] pub selective: Option, } diff --git a/src/types/reply_markup.rs b/src/types/reply_markup.rs index 3db4f1d6..fd7a7306 100644 --- a/src/types/reply_markup.rs +++ b/src/types/reply_markup.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{ ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, }; diff --git a/src/types/response_parameters.rs b/src/types/response_parameters.rs index ca796f09..f885d36c 100644 --- a/src/types/response_parameters.rs +++ b/src/types/response_parameters.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// Contains information about why a request was unsuccessful. /// /// [The official docs](https://core.telegram.org/bots/api#responseparameters). diff --git a/src/types/send_invoice.rs b/src/types/send_invoice.rs index e7952ebb..6ebf1feb 100644 --- a/src/types/send_invoice.rs +++ b/src/types/send_invoice.rs @@ -1,5 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice}; +// TODO: missing docs +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct SendInvoice { pub chat_id: ChatId, diff --git a/src/types/shipping_address.rs b/src/types/shipping_address.rs index 59ea2bd3..490c1586 100644 --- a/src/types/shipping_address.rs +++ b/src/types/shipping_address.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a shipping address. /// /// [The official docs](https://core.telegram.org/bots/api#shippingaddress). diff --git a/src/types/shipping_option.rs b/src/types/shipping_option.rs index b631973c..597592a9 100644 --- a/src/types/shipping_option.rs +++ b/src/types/shipping_option.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::LabeledPrice; /// This object represents one shipping option. diff --git a/src/types/shipping_query.rs b/src/types/shipping_query.rs index 7f99f7af..63e33850 100644 --- a/src/types/shipping_query.rs +++ b/src/types/shipping_query.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{ShippingAddress, User}; /// This object contains information about an incoming shipping query. diff --git a/src/types/sticker.rs b/src/types/sticker.rs index 93d1b028..4fb139f8 100644 --- a/src/types/sticker.rs +++ b/src/types/sticker.rs @@ -1,8 +1,11 @@ +use serde::{Deserialize, Serialize}; + use crate::types::{MaskPosition, PhotoSize}; /// This object represents a sticker. /// /// [The official docs](https://core.telegram.org/bots/api#sticker). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Sticker { /// Identifier for this file. diff --git a/src/types/sticker_set.rs b/src/types/sticker_set.rs index 9219d90c..612b83f8 100644 --- a/src/types/sticker_set.rs +++ b/src/types/sticker_set.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::Sticker; /// This object represents a sticker set. diff --git a/src/types/successful_payment.rs b/src/types/successful_payment.rs index 8519d0be..36a84c54 100644 --- a/src/types/successful_payment.rs +++ b/src/types/successful_payment.rs @@ -1,8 +1,11 @@ +use serde::{Deserialize, Serialize}; + use crate::types::OrderInfo; /// This object contains basic information about a successful payment. /// /// [The official docs](https://core.telegram.org/bots/api#successfulpayment). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct SuccessfulPayment { /// Three-letter ISO 4217 [currency] code. diff --git a/src/types/unit_false.rs b/src/types/unit_false.rs index 3000a917..7821f313 100644 --- a/src/types/unit_false.rs +++ b/src/types/unit_false.rs @@ -7,7 +7,6 @@ impl std::convert::TryFrom for False { type Error = (); fn try_from(value: bool) -> Result { - #[allow(clippy::match_bool)] match value { true => Err(()), false => Ok(False), @@ -40,7 +39,6 @@ impl<'de> Visitor<'de> for FalseVisitor { where E: serde::de::Error, { - #[allow(clippy::match_bool)] match value { true => Err(E::custom("expected `false`, found `true`")), false => Ok(False), diff --git a/src/types/unit_true.rs b/src/types/unit_true.rs index 4bba4dd2..619cb7cc 100644 --- a/src/types/unit_true.rs +++ b/src/types/unit_true.rs @@ -10,7 +10,6 @@ impl std::convert::TryFrom for True { type Error = (); fn try_from(value: bool) -> Result { - #[allow(clippy::match_bool)] match value { true => Ok(True), false => Err(()), @@ -40,7 +39,6 @@ impl<'de> Visitor<'de> for TrueVisitor { where E: de::Error, { - #[allow(clippy::match_bool)] match value { true => Ok(True), false => Err(E::custom("expected `true`, found `false`")), diff --git a/src/types/update.rs b/src/types/update.rs index b49a1254..5f3b9d7c 100644 --- a/src/types/update.rs +++ b/src/types/update.rs @@ -1,5 +1,7 @@ #![allow(clippy::large_enum_variant)] +use serde::{Deserialize, Serialize}; + use crate::types::{CallbackQuery, ChosenInlineResult, InlineQuery, Message}; /// This [object] represents an incoming update. diff --git a/src/types/user.rs b/src/types/user.rs index 2ed37bcb..a6c75512 100644 --- a/src/types/user.rs +++ b/src/types/user.rs @@ -1,6 +1,9 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a Telegram user or bot. /// /// [The official docs](https://core.telegram.org/bots/api#user). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct User { /// Unique identifier for this user or bot. diff --git a/src/types/user_profile_photos.rs b/src/types/user_profile_photos.rs index 0c40b554..9af7b401 100644 --- a/src/types/user_profile_photos.rs +++ b/src/types/user_profile_photos.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::PhotoSize; /// This object represent a user's profile pictures. diff --git a/src/types/venue.rs b/src/types/venue.rs index d7f70fac..ef8bddc3 100644 --- a/src/types/venue.rs +++ b/src/types/venue.rs @@ -1,6 +1,9 @@ +use serde::{Deserialize, Serialize}; + use crate::types::Location; /// This object represents a venue. +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct Venue { /// Venue location. @@ -13,12 +16,10 @@ pub struct Venue { pub address: String, /// Foursquare identifier of the venue. - #[serde(skip_serializing_if = "Option::is_none")] pub foursquare_id: Option, /// Foursquare type of the venue. (For example, /// `arts_entertainment/default`, `arts_entertainment/aquarium` or /// `food/icecream`.) - #[serde(skip_serializing_if = "Option::is_none")] - pub foursquare_type: Option, // TODO: is this enum?... + pub foursquare_type: Option, } diff --git a/src/types/video.rs b/src/types/video.rs index f92dc52d..2b9fae08 100644 --- a/src/types/video.rs +++ b/src/types/video.rs @@ -1,8 +1,11 @@ +use serde::{Deserialize, Serialize}; + use crate::types::PhotoSize; /// This object represents a video file. /// /// [The official docs](https://core.telegram.org/bots/api#video). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Video { /// Identifier for this file. diff --git a/src/types/video_note.rs b/src/types/video_note.rs index a4ee4c88..096170f8 100644 --- a/src/types/video_note.rs +++ b/src/types/video_note.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::types::PhotoSize; /// This object represents a [video message] (available in Telegram apps as of @@ -7,6 +9,7 @@ use crate::types::PhotoSize; /// /// [video message]: 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)] pub struct VideoNote { /// Identifier for this file. diff --git a/src/types/voice.rs b/src/types/voice.rs index ee47f461..77ff8c5f 100644 --- a/src/types/voice.rs +++ b/src/types/voice.rs @@ -1,6 +1,9 @@ +use serde::{Deserialize, Serialize}; + /// This object represents a voice note. /// /// [The official docs](https://core.telegram.org/bots/api#voice). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Voice { /// Identifier for this file. diff --git a/src/types/webhook_info.rs b/src/types/webhook_info.rs index 07995be4..0bda1b30 100644 --- a/src/types/webhook_info.rs +++ b/src/types/webhook_info.rs @@ -1,6 +1,9 @@ +use serde::{Deserialize, Serialize}; + /// Contains information about the current status of a webhook. /// /// [The official docs](https://core.telegram.org/bots/api#webhookinfo). +#[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct WebhookInfo { /// Webhook URL, may be empty if webhook is not set up.