diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 96472626..1a818920 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -1,24 +1,15 @@ use reqwest::r#async::Client; use crate::core::{ - types::{ - InputFile, - InputMedia, - }, requests::{ - ChatId, - RequestContext, - - get_me::GetMe, - send_message::SendMessage, edit_message_live_location::EditMessageLiveLocation, - forward_message::ForwardMessage, - send_audio::SendAudio, - send_location::SendLocation, - send_media_group::SendMediaGroup, - send_photo::SendPhoto, - stop_message_live_location::StopMessageLiveLocation, - } + forward_message::ForwardMessage, get_me::GetMe, send_audio::SendAudio, + send_location::SendLocation, send_media_group::SendMediaGroup, + send_message::SendMessage, send_photo::SendPhoto, + stop_message_live_location::StopMessageLiveLocation, ChatId, + RequestContext, + }, + types::{InputFile, InputMedia}, }; pub struct Bot { @@ -60,11 +51,7 @@ impl Bot { C: Into, T: Into, { - SendMessage::new( - self.ctx(), - chat_id.into(), - text.into(), - ) + SendMessage::new(self.ctx(), chat_id.into(), text.into()) } pub fn edit_message_live_location( @@ -87,7 +74,7 @@ impl Bot { &self, chat_id: C, from_chat_id: F, - message_id: M + message_id: M, ) -> ForwardMessage where C: Into, @@ -107,11 +94,7 @@ impl Bot { C: Into, A: Into, { - SendAudio::new( - self.ctx(), - chat_id.into(), - audio.into() - ) + SendAudio::new(self.ctx(), chat_id.into(), audio.into()) } pub fn send_location( @@ -136,30 +119,20 @@ impl Bot { pub fn send_media_group(&self, chat_id: C, media: M) -> SendMediaGroup where C: Into, - M: Into> + M: Into>, { - SendMediaGroup::new( - self.ctx(), - chat_id.into(), - media.into(), - ) + SendMediaGroup::new(self.ctx(), chat_id.into(), media.into()) } pub fn send_photo(&self, chat_id: C, photo: P) -> SendPhoto where C: Into, - P: Into + P: Into, { - SendPhoto::new( - self.ctx(), - chat_id.into(), - photo.into(), - ) + SendPhoto::new(self.ctx(), chat_id.into(), photo.into()) } pub fn stop_message_live_location(&self) -> StopMessageLiveLocation { - StopMessageLiveLocation::new( - self.ctx() - ) + StopMessageLiveLocation::new(self.ctx()) } } diff --git a/src/core/requests/answer_pre_checkout_query.rs b/src/core/requests/answer_pre_checkout_query.rs index fb995ae2..f494ead8 100644 --- a/src/core/requests/answer_pre_checkout_query.rs +++ b/src/core/requests/answer_pre_checkout_query.rs @@ -1,6 +1,6 @@ use crate::core::{ - requests::{RequestContext, Request, RequestFuture, ResponseResult}, - network + network, + requests::{Request, RequestContext, RequestFuture, ResponseResult}, }; #[derive(Debug, Serialize, Clone)] @@ -40,8 +40,9 @@ impl<'a> Request<'a> for AnswerPreCheckoutQuery<'a> { &self.ctx.client, &self.ctx.token, "answerPreCheckoutQuery", - &self - ).await + &self, + ) + .await }) } } @@ -50,32 +51,35 @@ impl<'a> AnswerPreCheckoutQuery<'a> { pub(crate) fn new( ctx: RequestContext<'a>, pre_checkout_query_id: String, - ok: bool + ok: bool, ) -> Self { Self { ctx, pre_checkout_query_id, ok, - error_message: None + error_message: None, } } pub fn pre_checkout_query_id(mut self, pre_checkout_query_id: T) -> Self - where T: Into + where + T: Into, { self.pre_checkout_query_id = pre_checkout_query_id.into(); self } pub fn ok(mut self, ok: T) -> Self - where T: Into + where + T: Into, { self.ok = ok.into(); self } pub fn error_message(mut self, error_message: T) -> Self - where T: Into + where + T: Into, { self.error_message = Some(error_message.into()); self diff --git a/src/core/requests/answer_shipping_query.rs b/src/core/requests/answer_shipping_query.rs index 74728d92..c66860c9 100644 --- a/src/core/requests/answer_shipping_query.rs +++ b/src/core/requests/answer_shipping_query.rs @@ -1,6 +1,8 @@ -use crate::core::types::ShippingOption; -use crate::core::requests::{RequestContext, Request, RequestFuture, ResponseResult}; use crate::core::network; +use crate::core::requests::{ + Request, RequestContext, RequestFuture, ResponseResult, +}; +use crate::core::types::ShippingOption; #[derive(Debug, Clone, Serialize)] /// If you sent an invoice requesting a shipping address and the parameter @@ -40,8 +42,9 @@ impl<'a> Request<'a> for AnswerShippingQuery<'a> { &self.ctx.client, &self.ctx.token, "answerShippingQuery", - &self - ).await + &self, + ) + .await }) } } @@ -50,40 +53,44 @@ impl<'a> AnswerShippingQuery<'a> { pub(crate) fn new( ctx: RequestContext<'a>, shipping_query_id: String, - ok: bool + ok: bool, ) -> Self { Self { ctx, shipping_query_id, ok, shipping_options: None, - error_message: None + error_message: None, } } pub fn shipping_query_id(mut self, shipping_query_id: T) -> Self - where T: Into + where + T: Into, { self.shipping_query_id = shipping_query_id.into(); self } pub fn ok(mut self, ok: T) -> Self - where T: Into + where + T: Into, { self.ok = ok.into(); self } pub fn shipping_options(mut self, shipping_options: T) -> Self - where T: Into> + where + T: Into>, { self.shipping_options = Some(shipping_options.into()); self } pub fn error_message(mut self, error_message: T) -> Self - where T: Into + where + T: Into, { self.error_message = Some(error_message.into()); self diff --git a/src/core/requests/forward_message.rs b/src/core/requests/forward_message.rs index 2de100f4..ec24a7e3 100644 --- a/src/core/requests/forward_message.rs +++ b/src/core/requests/forward_message.rs @@ -1,11 +1,7 @@ use crate::core::{ network, requests::{ - ChatId, - Request, - RequestFuture, - RequestContext, - ResponseResult, + ChatId, Request, RequestContext, RequestFuture, ResponseResult, }, types::Message, }; diff --git a/src/core/requests/get_file.rs b/src/core/requests/get_file.rs index 01d04593..089ff743 100644 --- a/src/core/requests/get_file.rs +++ b/src/core/requests/get_file.rs @@ -1,9 +1,11 @@ -use crate::core::requests::{RequestContext, RequestFuture, ResponseResult, Request}; -use crate::core::types::File; use crate::core::network; +use crate::core::requests::{ + Request, RequestContext, RequestFuture, ResponseResult, +}; +use crate::core::types::File; -/// Use this method to get basic info about a file and prepare it for downloading. -/// For the moment, bots can download files of up to 20MB in size. +/// Use this method to get basic info about a file and prepare it for +/// downloading. For the moment, bots can download files of up to 20MB in size. /// On success, a File object is returned. /// The file can then be downloaded via the link https://api.telegram.org/file/bot/, /// where is taken from the response. @@ -14,10 +16,9 @@ struct GetFile<'a> { #[serde(skip_serializing)] ctx: RequestContext<'a>, /// File identifier to get info about - file_id: String + file_id: String, } - impl<'a> Request<'a> for GetFile<'a> { type ReturnValue = File; @@ -29,16 +30,15 @@ impl<'a> Request<'a> for GetFile<'a> { "getFile", &self, ) - .await + .await }) } } - -impl<'a> GetFile<'a>{ +impl<'a> GetFile<'a> { pub fn file_id(mut self, file_id: T) -> Self - where - T: Into, + where + T: Into, { self.file_id = file_id.into(); self diff --git a/src/core/requests/send_chat_action.rs b/src/core/requests/send_chat_action.rs index 9ab28bee..ae07ec05 100644 --- a/src/core/requests/send_chat_action.rs +++ b/src/core/requests/send_chat_action.rs @@ -1,9 +1,12 @@ use crate::core::network; -use crate::core::requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult}; +use crate::core::requests::{ + ChatId, Request, RequestContext, RequestFuture, ResponseResult, +}; -///Use this method when you need to tell the user that something is happening on the bot's side. -///The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). -///Returns True on success. +///Use this method when you need to tell the user that something is happening +/// on the bot's side. The status is set for 5 seconds or less (when a message +/// arrives from your bot, Telegram clients clear its typing status). +/// Returns True on success. #[derive(Debug, Clone, Serialize)] struct SendChatAction<'a> { #[serde(skip_serializing)] @@ -45,7 +48,7 @@ impl<'a> Request<'a> for SendChatAction<'a> { "sendChatAction", &self, ) - .await + .await }) } } @@ -64,19 +67,18 @@ impl<'a> SendChatAction<'a> { } pub fn chat_id(mut self, chat_id: T) -> Self - where - T: Into, + where + T: Into, { self.chat_id = chat_id.into(); self } - pub fn action(mut self, action: T) -> Self - where - T: Into, + where + T: Into, { self.action = action.into(); self } -} \ No newline at end of file +} diff --git a/src/core/requests/send_message.rs b/src/core/requests/send_message.rs index ed0fcf85..2539c04d 100644 --- a/src/core/requests/send_message.rs +++ b/src/core/requests/send_message.rs @@ -1,11 +1,7 @@ use crate::core::{ network, requests::{ - ChatId, - Request, - RequestFuture, - RequestContext, - ResponseResult, + ChatId, Request, RequestContext, RequestFuture, ResponseResult, }, types::{Message, ParseMode, ReplyMarkup}, }; diff --git a/src/core/requests/stop_message_live_location.rs b/src/core/requests/stop_message_live_location.rs index c86ee1ed..5fb62a54 100644 --- a/src/core/requests/stop_message_live_location.rs +++ b/src/core/requests/stop_message_live_location.rs @@ -1,11 +1,7 @@ use crate::core::{ network, requests::{ - ChatId, - Request, - RequestFuture, - RequestContext, - ResponseResult, + ChatId, Request, RequestContext, RequestFuture, ResponseResult, }, types::{InlineKeyboardMarkup, Message}, }; diff --git a/src/core/requests/utils.rs b/src/core/requests/utils.rs index 193bad0c..90f9c409 100644 --- a/src/core/requests/utils.rs +++ b/src/core/requests/utils.rs @@ -2,11 +2,7 @@ use std::path::PathBuf; use bytes::{Bytes, BytesMut}; use reqwest::r#async::multipart::Part; -use tokio::{ - prelude::*, - codec::FramedRead, -}; - +use tokio::{codec::FramedRead, prelude::*}; struct FileDecoder; diff --git a/src/core/types/animation.rs b/src/core/types/animation.rs index 4a60e4c5..5d2ceff1 100644 --- a/src/core/types/animation.rs +++ b/src/core/types/animation.rs @@ -19,7 +19,7 @@ pub struct Animation { /// Optional. MIME type of the file as defined by sender pub mime_type: Option, /// Optional. File size - pub file_size: Option + pub file_size: Option, } #[cfg(test)] @@ -51,11 +51,11 @@ mod tests { file_id: "id".to_string(), width: 320, height: 320, - file_size: Some(3452) + file_size: Some(3452), }), file_name: Some("some".to_string()), mime_type: Some("gif".to_string()), - file_size: Some(6500) + file_size: Some(6500), }; let actual = serde_json::from_str::(json).unwrap(); assert_eq!(actual, expected) diff --git a/src/core/types/callback_query.rs b/src/core/types/callback_query.rs index 62dae596..edcbe996 100644 --- a/src/core/types/callback_query.rs +++ b/src/core/types/callback_query.rs @@ -1,6 +1,7 @@ -use crate::core::types::{User, Message}; +use crate::core::types::{Message, User}; -/// This object represents an incoming callback query from a callback button in an inline keyboard. +/// This object represents an incoming callback query from a callback button in +/// an inline keyboard. #[derive(Debug, Deserialize, PartialEq, Clone)] pub struct CallbackQuery { /// Unique identifier for this query @@ -8,12 +9,14 @@ pub struct CallbackQuery { /// Sender pub from: User, /// Message with the callback button that originated the query. - /// Note that message content and message date will not be available if the message is too old + /// Note that message content and message date will not be available if the + /// message is too old pub message: Message, - /// Global identifier, uniquely corresponding to the chat to which the message - /// with the callback button was sent. Useful for high scores in games. + /// Global identifier, uniquely corresponding to the chat to which the + /// message with the callback button was sent. Useful for high scores + /// in games. pub chat_instance: String, - /// Data associated with the callback button. Be aware that a bad client can - /// send arbitrary data in this field. + /// Data associated with the callback button. Be aware that a bad client + /// can send arbitrary data in this field. pub data: String, -} \ No newline at end of file +} diff --git a/src/core/types/chat.rs b/src/core/types/chat.rs index b27e7686..34469b48 100644 --- a/src/core/types/chat.rs +++ b/src/core/types/chat.rs @@ -1,6 +1,5 @@ use crate::core::types::{ChatPermissions, ChatPhoto, Message}; - #[derive(Debug, Deserialize, PartialEq, Clone)] pub struct Chat { pub id: i64, @@ -9,7 +8,6 @@ pub struct Chat { pub photo: Option, } - #[derive(Debug, Deserialize, PartialEq, Clone)] #[serde(untagged)] pub enum ChatKind { diff --git a/src/core/types/chosen_inline_result.rs b/src/core/types/chosen_inline_result.rs index 9821fde2..800c0a44 100644 --- a/src/core/types/chosen_inline_result.rs +++ b/src/core/types/chosen_inline_result.rs @@ -1,4 +1,4 @@ -use crate::core::types::{User, Location}; +use crate::core::types::{Location, User}; #[derive(Debug, Deserialize, Clone, PartialEq)] /// Represents a result of an inline query that was chosen by the user and @@ -11,9 +11,9 @@ pub struct ChosenInlineResult { pub from: User, /// Optional. Sender location, only for bots that require user location pub location: Option, - /// Optional. Identifier of the sent inline message. Available only if there is an inline - /// keyboard attached to the message. Will be also received in callback queries and can - /// be used to edit the message. + /// Optional. Identifier of the sent inline message. Available only if + /// there is an inline keyboard attached to the message. Will be also + /// received in callback queries and can be used to edit the message. pub inline_message_id: Option, /// The query that was used to obtain the result pub query: String, diff --git a/src/core/types/contact.rs b/src/core/types/contact.rs index d5ffedca..15933ff6 100644 --- a/src/core/types/contact.rs +++ b/src/core/types/contact.rs @@ -12,4 +12,4 @@ pub struct Contact { /// Optional. Additional data about the contact in the form of a /// [vCard](https://en.wikipedia.org/wiki/VCard) pub vcard: Option, -} \ No newline at end of file +} diff --git a/src/core/types/file.rs b/src/core/types/file.rs index 88ce6e97..e72f81ba 100644 --- a/src/core/types/file.rs +++ b/src/core/types/file.rs @@ -2,5 +2,5 @@ pub struct File { pub file_id: String, pub file_size: u32, - pub file_path: String + pub file_path: String, } diff --git a/src/core/types/game.rs b/src/core/types/game.rs index bdd43adb..6fc488ac 100644 --- a/src/core/types/game.rs +++ b/src/core/types/game.rs @@ -1,10 +1,10 @@ use serde::Deserialize; -use crate::core::types::{MessageEntity, PhotoSize, Animation}; +use crate::core::types::{Animation, MessageEntity, PhotoSize}; #[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)] -/// This object represents a game. Use BotFather to create and edit games, their short names -/// will act as unique identifiers. +/// This object represents a game. Use BotFather to create and edit games, their +/// short names will act as unique identifiers. pub struct Game { /// Title of the game pub title: String, @@ -12,13 +12,15 @@ pub struct Game { pub description: String, /// Photo that will be displayed in the game message in chats. pub photo: Vec, - /// Optional. Brief description of the game or high scores included in the game message. - /// Can be automatically edited to include current high scores for the game when - /// the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. + /// Optional. Brief description of the game or high scores included in the + /// game message. Can be automatically edited to include current high + /// scores for the game when the bot calls setGameScore, or manually + /// edited using editMessageText. 0-4096 characters. pub text: Option, - /// Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. + /// Optional. Special entities that appear in text, such as usernames, + /// URLs, bot commands, etc. pub text_entities: Option>, - /// Optional. Animation that will be displayed in the game message in chats. - /// Upload via BotFather + /// Optional. Animation that will be displayed in the game message in + /// chats. Upload via BotFather pub animation: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_keyboard_button.rs b/src/core/types/inline_keyboard_button.rs index ba2bcc4f..228f83f7 100644 --- a/src/core/types/inline_keyboard_button.rs +++ b/src/core/types/inline_keyboard_button.rs @@ -62,32 +62,37 @@ impl InlineKeyboardButton { } } - pub fn callback(text: String, callback_data: String) - -> InlineKeyboardButton { + pub fn callback( + text: String, + callback_data: String, + ) -> InlineKeyboardButton { InlineKeyboardButton { text, kind: InlineKeyboardButtonKind::CallbackData(callback_data), } } - pub fn switch_inline_query(text: String, switch_inline_query: String) - -> InlineKeyboardButton { + pub fn switch_inline_query( + text: String, + switch_inline_query: String, + ) -> InlineKeyboardButton { InlineKeyboardButton { text, - kind: InlineKeyboardButtonKind::SwitchInlineQuery(switch_inline_query) + kind: InlineKeyboardButtonKind::SwitchInlineQuery( + switch_inline_query, + ), } } pub fn switch_inline_query_current_chat( text: String, - switch_inline_query_current_chat: String + switch_inline_query_current_chat: String, ) -> InlineKeyboardButton { - InlineKeyboardButton { text, kind: InlineKeyboardButtonKind::SwitchInlineQueryCurrentChat( - switch_inline_query_current_chat - ) + switch_inline_query_current_chat, + ), } } } diff --git a/src/core/types/inline_keyboard_markup.rs b/src/core/types/inline_keyboard_markup.rs index 37c753a4..9e02ed2e 100644 --- a/src/core/types/inline_keyboard_markup.rs +++ b/src/core/types/inline_keyboard_markup.rs @@ -17,22 +17,19 @@ pub struct InlineKeyboardMarkup { /// Example: /// ``` /// use async_telegram_bot::core::types::{ -/// InlineKeyboardMarkup, -/// InlineKeyboardButton +/// InlineKeyboardButton, InlineKeyboardMarkup, /// }; /// -/// /// let url_button = InlineKeyboardButton::url( /// "text".to_string(), -/// "http://url.com".to_string() +/// "http://url.com".to_string(), /// ); -/// let keyboard = InlineKeyboardMarkup::new() -/// .append_row(vec![url_button]); +/// let keyboard = InlineKeyboardMarkup::new().append_row(vec![url_button]); /// ``` impl InlineKeyboardMarkup { pub fn new() -> Self { Self { - inline_keyboard: vec![] + inline_keyboard: vec![], } } @@ -41,11 +38,14 @@ impl InlineKeyboardMarkup { self } - pub fn append_to_row(mut self, button: InlineKeyboardButton, index: usize) - -> Self { + pub fn append_to_row( + mut self, + button: InlineKeyboardButton, + index: usize, + ) -> Self { match self.inline_keyboard.get_mut(index) { Some(buttons) => buttons.push(button), - None => self.inline_keyboard.push(vec![button]) + None => self.inline_keyboard.push(vec![button]), }; self } @@ -68,9 +68,7 @@ mod tests { let markup = InlineKeyboardMarkup::new() .append_row(vec![button1.clone(), button2.clone()]); let expected = InlineKeyboardMarkup { - inline_keyboard: vec![ - vec![button1.clone(), button2.clone()] - ] + inline_keyboard: vec![vec![button1.clone(), button2.clone()]], }; assert_eq!(markup, expected); } @@ -89,9 +87,7 @@ mod tests { .append_row(vec![button1.clone()]) .append_to_row(button2.clone(), 0); let expected = InlineKeyboardMarkup { - inline_keyboard: vec![ - vec![button1.clone(), button2.clone()] - ] + inline_keyboard: vec![vec![button1.clone(), button2.clone()]], }; assert_eq!(markup, expected); } @@ -110,10 +106,7 @@ mod tests { .append_row(vec![button1.clone()]) .append_to_row(button2.clone(), 1); let expected = InlineKeyboardMarkup { - inline_keyboard: vec![ - vec![button1.clone()], - vec![button2.clone()] - ] + inline_keyboard: vec![vec![button1.clone()], vec![button2.clone()]], }; assert_eq!(markup, expected); } diff --git a/src/core/types/inline_query.rs b/src/core/types/inline_query.rs index 7a1fa571..c3e99ae7 100644 --- a/src/core/types/inline_query.rs +++ b/src/core/types/inline_query.rs @@ -1,4 +1,4 @@ -use crate::core::types::{User, Location}; +use crate::core::types::{Location, User}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQuery { diff --git a/src/core/types/inline_query_result.rs b/src/core/types/inline_query_result.rs index 144c1cc4..755528f5 100644 --- a/src/core/types/inline_query_result.rs +++ b/src/core/types/inline_query_result.rs @@ -1,26 +1,16 @@ use crate::core::types::{ - InlineQueryResultCachedAudio, - InlineQueryResultCachedDocument, - InlineQueryResultCachedGif, - InlineQueryResultCachedMpeg4Gif, - InlineQueryResultCachedPhoto, - InlineQueryResultCachedSticker, - InlineQueryResultCachedVideo, - InlineQueryResultCachedVoice, - InlineQueryResultArticle, - InlineQueryResultAudio, - InlineQueryResultContact, - InlineQueryResultGame, - InlineQueryResultDocument, - InlineQueryResultGif, - InlineQueryResultLocation, - InlineQueryResultMpeg4Gif, - InlineQueryResultPhoto, - InlineQueryResultVenue, - InlineQueryResultVideo, - InlineQueryResultVoice + InlineQueryResultArticle, InlineQueryResultAudio, + InlineQueryResultCachedAudio, InlineQueryResultCachedDocument, + InlineQueryResultCachedGif, InlineQueryResultCachedMpeg4Gif, + InlineQueryResultCachedPhoto, InlineQueryResultCachedSticker, + InlineQueryResultCachedVideo, InlineQueryResultCachedVoice, + InlineQueryResultContact, InlineQueryResultDocument, InlineQueryResultGame, + InlineQueryResultGif, InlineQueryResultLocation, InlineQueryResultMpeg4Gif, + InlineQueryResultPhoto, InlineQueryResultVenue, InlineQueryResultVideo, + InlineQueryResultVoice, }; +/// This object represents one result of an inline query. #[derive(Debug, Serialize, PartialEq, Clone)] #[serde(tag = "type")] #[serde(rename_all = "snake_case")] @@ -59,24 +49,26 @@ pub enum InlineQueryResult { #[cfg(test)] mod tests { - use crate::core::types::{InlineQueryResult, InlineQueryResultCachedAudio, InputMessageContent}; - use crate::core::types::parse_mode::ParseMode; use crate::core::types::inline_keyboard_markup::InlineKeyboardMarkup; + use crate::core::types::parse_mode::ParseMode; + use crate::core::types::{ + InlineQueryResult, InlineQueryResultCachedAudio, InputMessageContent, + }; #[test] fn cached_audio_min_serialize() { - let structure = InlineQueryResult::CachedAudio( - InlineQueryResultCachedAudio { + let structure = + InlineQueryResult::CachedAudio(InlineQueryResultCachedAudio { id: String::from("id"), audio_file_id: String::from("audio_file_id"), caption: None, parse_mode: None, reply_markup: None, - input_message_content: None - } - ); + input_message_content: None, + }); - let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id"}"#; + let expected_json = + r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id"}"#; let actual_json = serde_json::to_string(&structure).unwrap(); assert_eq!(expected_json, actual_json); @@ -84,8 +76,8 @@ mod tests { #[test] fn cached_audio_full_serialize() { - let structure = InlineQueryResult::CachedAudio( - InlineQueryResultCachedAudio { + let structure = + InlineQueryResult::CachedAudio(InlineQueryResultCachedAudio { id: String::from("id"), audio_file_id: String::from("audio_file_id"), caption: Some(String::from("caption")), @@ -94,10 +86,9 @@ mod tests { input_message_content: Some(InputMessageContent::Text { message_text: String::from("message_text"), parse_mode: Some(ParseMode::Markdown), - disable_web_page_preview: Some(true) - }) - } - ); + disable_web_page_preview: Some(true), + }), + }); let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"Markdown","disable_web_page_preview":true}}"#; let actual_json = serde_json::to_string(&structure).unwrap(); @@ -106,4 +97,4 @@ mod tests { } // TODO: Add more tests -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_article.rs b/src/core/types/inline_query_result_article.rs index b887c75d..1edda355 100644 --- a/src/core/types/inline_query_result_article.rs +++ b/src/core/types/inline_query_result_article.rs @@ -1,4 +1,4 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup}; +use crate::core::types::{InlineKeyboardMarkup, InputMessageContent}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultArticle { @@ -14,7 +14,8 @@ pub struct InlineQueryResultArticle { /// Optional. URL of the result #[serde(skip_serializing_if = "Option::is_none")] pub url: Option, - /// Optional. Pass True, if you don't want the URL to be shown in the message + /// Optional. 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, /// Optional. Short description of the result diff --git a/src/core/types/inline_query_result_audio.rs b/src/core/types/inline_query_result_audio.rs index ac8d40b8..867cb237 100644 --- a/src/core/types/inline_query_result_audio.rs +++ b/src/core/types/inline_query_result_audio.rs @@ -1,4 +1,6 @@ -use crate::core::types::{ParseMode, InlineKeyboardMarkup, InputMessageContent}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultAudio { @@ -17,4 +19,4 @@ pub struct InlineQueryResultAudio { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_audio.rs b/src/core/types/inline_query_result_cached_audio.rs index 6975dbd6..89b7944e 100644 --- a/src/core/types/inline_query_result_cached_audio.rs +++ b/src/core/types/inline_query_result_cached_audio.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedAudio { @@ -12,4 +14,4 @@ pub struct InlineQueryResultCachedAudio { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_document.rs b/src/core/types/inline_query_result_cached_document.rs index c821ffa7..f79487bc 100644 --- a/src/core/types/inline_query_result_cached_document.rs +++ b/src/core/types/inline_query_result_cached_document.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedDocument { @@ -15,4 +17,4 @@ pub struct InlineQueryResultCachedDocument { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_gif.rs b/src/core/types/inline_query_result_cached_gif.rs index ab1dc7d6..c81170c4 100644 --- a/src/core/types/inline_query_result_cached_gif.rs +++ b/src/core/types/inline_query_result_cached_gif.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedGif { @@ -14,4 +16,4 @@ pub struct InlineQueryResultCachedGif { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_mpeg4_gif.rs b/src/core/types/inline_query_result_cached_mpeg4_gif.rs index 8763142b..cbc46c75 100644 --- a/src/core/types/inline_query_result_cached_mpeg4_gif.rs +++ b/src/core/types/inline_query_result_cached_mpeg4_gif.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedMpeg4Gif { @@ -14,4 +16,4 @@ pub struct InlineQueryResultCachedMpeg4Gif { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_photo.rs b/src/core/types/inline_query_result_cached_photo.rs index f012b56d..d5317a17 100644 --- a/src/core/types/inline_query_result_cached_photo.rs +++ b/src/core/types/inline_query_result_cached_photo.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedPhoto { @@ -16,4 +18,4 @@ pub struct InlineQueryResultCachedPhoto { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_sticker.rs b/src/core/types/inline_query_result_cached_sticker.rs index 037cc670..703ea199 100644 --- a/src/core/types/inline_query_result_cached_sticker.rs +++ b/src/core/types/inline_query_result_cached_sticker.rs @@ -1,4 +1,4 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup}; +use crate::core::types::{InlineKeyboardMarkup, InputMessageContent}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedSticker { @@ -8,4 +8,4 @@ pub struct InlineQueryResultCachedSticker { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_video.rs b/src/core/types/inline_query_result_cached_video.rs index 2bebfdff..216ffe8a 100644 --- a/src/core/types/inline_query_result_cached_video.rs +++ b/src/core/types/inline_query_result_cached_video.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedVideo { @@ -15,4 +17,4 @@ pub struct InlineQueryResultCachedVideo { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_cached_voice.rs b/src/core/types/inline_query_result_cached_voice.rs index e0ec1074..e15b75bc 100644 --- a/src/core/types/inline_query_result_cached_voice.rs +++ b/src/core/types/inline_query_result_cached_voice.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultCachedVoice { @@ -13,4 +15,4 @@ pub struct InlineQueryResultCachedVoice { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_contact.rs b/src/core/types/inline_query_result_contact.rs index 0c0d22b7..fb4b2d28 100644 --- a/src/core/types/inline_query_result_contact.rs +++ b/src/core/types/inline_query_result_contact.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultContact { @@ -19,4 +21,4 @@ pub struct InlineQueryResultContact { pub thumb_width: Option, #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_document.rs b/src/core/types/inline_query_result_document.rs index 7ff3bf44..d65a735d 100644 --- a/src/core/types/inline_query_result_document.rs +++ b/src/core/types/inline_query_result_document.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultDocument { @@ -22,4 +24,4 @@ pub struct InlineQueryResultDocument { pub thumb_width: Option, #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_game.rs b/src/core/types/inline_query_result_game.rs index 942eb2b5..f19aa16f 100644 --- a/src/core/types/inline_query_result_game.rs +++ b/src/core/types/inline_query_result_game.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, Hash, PartialEq, Eq, Clone)] pub struct InlineQueryResultGame { @@ -6,4 +8,4 @@ pub struct InlineQueryResultGame { pub game_short_name: String, #[serde(skip_serializing_if = "Option::is_none")] pub reply_markup: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_gif.rs b/src/core/types/inline_query_result_gif.rs index c86d634a..7131d35a 100644 --- a/src/core/types/inline_query_result_gif.rs +++ b/src/core/types/inline_query_result_gif.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultGif { @@ -21,4 +23,4 @@ pub struct InlineQueryResultGif { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_location.rs b/src/core/types/inline_query_result_location.rs index 09c034f5..a89ca988 100644 --- a/src/core/types/inline_query_result_location.rs +++ b/src/core/types/inline_query_result_location.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultLocation { @@ -18,4 +20,4 @@ pub struct InlineQueryResultLocation { pub thumb_width: Option, #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_mpeg4_gif.rs b/src/core/types/inline_query_result_mpeg4_gif.rs index 186cdba1..b690746f 100644 --- a/src/core/types/inline_query_result_mpeg4_gif.rs +++ b/src/core/types/inline_query_result_mpeg4_gif.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultMpeg4Gif { @@ -21,4 +23,4 @@ pub struct InlineQueryResultMpeg4Gif { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_photo.rs b/src/core/types/inline_query_result_photo.rs index cf2b4b51..d0626100 100644 --- a/src/core/types/inline_query_result_photo.rs +++ b/src/core/types/inline_query_result_photo.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultPhoto { @@ -21,4 +23,4 @@ pub struct InlineQueryResultPhoto { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_venue.rs b/src/core/types/inline_query_result_venue.rs index e6beb38d..9237e001 100644 --- a/src/core/types/inline_query_result_venue.rs +++ b/src/core/types/inline_query_result_venue.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultVenue { @@ -21,4 +23,4 @@ pub struct InlineQueryResultVenue { pub thumb_width: Option, #[serde(skip_serializing_if = "Option::is_none")] pub thumb_height: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_video.rs b/src/core/types/inline_query_result_video.rs index 566eea6d..bc8660db 100644 --- a/src/core/types/inline_query_result_video.rs +++ b/src/core/types/inline_query_result_video.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultVideo { @@ -23,4 +25,4 @@ pub struct InlineQueryResultVideo { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/inline_query_result_voice.rs b/src/core/types/inline_query_result_voice.rs index 38d2de62..b4493fc1 100644 --- a/src/core/types/inline_query_result_voice.rs +++ b/src/core/types/inline_query_result_voice.rs @@ -1,4 +1,6 @@ -use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode}; +use crate::core::types::{ + InlineKeyboardMarkup, InputMessageContent, ParseMode, +}; #[derive(Debug, Serialize, PartialEq, Clone)] pub struct InlineQueryResultVoice { @@ -15,4 +17,4 @@ pub struct InlineQueryResultVoice { pub reply_markup: Option, #[serde(skip_serializing_if = "Option::is_none")] pub input_message_content: Option, -} \ No newline at end of file +} diff --git a/src/core/types/input_message_content.rs b/src/core/types/input_message_content.rs index d36f73b7..2c60ac5a 100644 --- a/src/core/types/input_message_content.rs +++ b/src/core/types/input_message_content.rs @@ -8,18 +8,20 @@ use crate::core::types::ParseMode; /// a result of an inline query. /// [More](https://core.telegram.org/bots/api#inputmessagecontent) pub enum InputMessageContent { - /// Represents the content of a text message to be sent as the result of an inline query. + /// Represents the content of a text message to be sent as the result of an + /// inline query. Text { /// Text of the message to be sent, 1-4096 characters message_text: String, /// Send [Markdown] or [HTML], - /// if you want Telegram apps to show [bold, italic, fixed-width text or inline URLs] - /// in the media caption. + /// if you want Telegram apps to show [bold, italic, fixed-width text + /// or inline URLs] in the media caption. /// /// [Markdown]: crate::core::types::ParseMode::Markdown /// [Html]: crate::core::types::ParseMode::Html - /// [bold, italic, fixed-width text or inline URLs]: crate::core::types::ParseMode + /// [bold, italic, fixed-width text or inline URLs]: + /// crate::core::types::ParseMode #[serde(skip_serializing_if = "Option::is_none")] parse_mode: Option, @@ -27,18 +29,21 @@ pub enum InputMessageContent { #[serde(skip_serializing_if = "Option::is_none")] disable_web_page_preview: Option, }, - /// Represents the content of a location message to be sent as the result of an inline query. + /// Represents the content of a location message to be sent as the result + /// of an inline query. Location { /// Latitude of the location in degrees latitude: f64, /// Longitude of the location in degrees longitude: f64, - /// Period in seconds for which the location can be updated, should be between 60 and 86400. + /// 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, }, - /// Represents the content of a venue message to be sent as the result of an inline query. + /// Represents the content of a venue message to be sent as the result of + /// an inline query. Venue { /// Latitude of the venue in degrees latitude: f64, @@ -53,12 +58,14 @@ pub enum InputMessageContent { #[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”.) + /// 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, }, - /// Represents the content of a contact message to be sent as the result of an inline query. + /// Represents the content of a contact message to be sent as the result of + /// an inline query. Contact { /// Contact's phone number phone_number: String, @@ -124,7 +131,8 @@ mod tests { #[test] fn contact_serialize() { - let expected_json = r#"{"phone_number":"+3800000000","first_name":"jhon"}"#; + let expected_json = + r#"{"phone_number":"+3800000000","first_name":"jhon"}"#; let contact_content = InputMessageContent::Contact { phone_number: String::from("+3800000000"), first_name: String::from("jhon"), @@ -135,4 +143,4 @@ mod tests { let actual_json = serde_json::to_string(&contact_content).unwrap(); assert_eq!(expected_json, actual_json); } -} \ No newline at end of file +} diff --git a/src/core/types/label_price.rs b/src/core/types/label_price.rs index b1d04e3d..3c8afe19 100644 --- a/src/core/types/label_price.rs +++ b/src/core/types/label_price.rs @@ -20,7 +20,7 @@ mod tests { fn serialize() { let labeled_price = LabeledPrice { label: "Label".to_string(), - amount: 60 + amount: 60, }; let expected = r#"{"label":"Label","amount":60}"#; let actual = serde_json::to_string(&labeled_price).unwrap(); diff --git a/src/core/types/location.rs b/src/core/types/location.rs index b560b1ef..d5d4e138 100644 --- a/src/core/types/location.rs +++ b/src/core/types/location.rs @@ -5,4 +5,4 @@ pub struct Location { pub longitude: f64, /// Latitude as defined by sender pub latitude: f64, -} \ No newline at end of file +} diff --git a/src/core/types/mask_position.rs b/src/core/types/mask_position.rs index 603181a6..09992bdf 100644 --- a/src/core/types/mask_position.rs +++ b/src/core/types/mask_position.rs @@ -5,4 +5,3 @@ pub struct MaskPosition { pub y_shift: f64, pub scale: f64, } - diff --git a/src/core/types/mod.rs b/src/core/types/mod.rs index 1d81a65e..42e9869a 100644 --- a/src/core/types/mod.rs +++ b/src/core/types/mod.rs @@ -10,12 +10,36 @@ pub use self::{ chosen_inline_result::ChosenInlineResult, contact::Contact, document::Document, + file::File, force_reply::ForceReply, game::Game, inline_keyboard_button::{InlineKeyboardButton, InlineKeyboardButtonKind}, inline_keyboard_markup::InlineKeyboardMarkup, + inline_query::InlineQuery, + inline_query_result::InlineQueryResult, + inline_query_result_article::InlineQueryResultArticle, + inline_query_result_audio::InlineQueryResultAudio, + inline_query_result_cached_audio::InlineQueryResultCachedAudio, + inline_query_result_cached_document::InlineQueryResultCachedDocument, + inline_query_result_cached_gif::InlineQueryResultCachedGif, + inline_query_result_cached_mpeg4_gif::InlineQueryResultCachedMpeg4Gif, + inline_query_result_cached_photo::InlineQueryResultCachedPhoto, + inline_query_result_cached_sticker::InlineQueryResultCachedSticker, + inline_query_result_cached_video::InlineQueryResultCachedVideo, + inline_query_result_cached_voice::InlineQueryResultCachedVoice, + inline_query_result_contact::InlineQueryResultContact, + inline_query_result_document::InlineQueryResultDocument, + inline_query_result_game::InlineQueryResultGame, + inline_query_result_gif::InlineQueryResultGif, + inline_query_result_location::InlineQueryResultLocation, + inline_query_result_mpeg4_gif::InlineQueryResultMpeg4Gif, + inline_query_result_photo::InlineQueryResultPhoto, + inline_query_result_venue::InlineQueryResultVenue, + inline_query_result_video::InlineQueryResultVideo, + inline_query_result_voice::InlineQueryResultVoice, input_file::InputFile, input_media::InputMedia, + input_message_content::InputMessageContent, invoice::Invoice, keyboard_button::KeyboardButton, label_price::LabeledPrice, @@ -46,31 +70,6 @@ pub use self::{ video::Video, video_note::VideoNote, voice::Voice, - file::File, - input_message_content::InputMessageContent, - - inline_query::InlineQuery, - inline_query_result::InlineQueryResult, - inline_query_result_cached_audio::InlineQueryResultCachedAudio, - inline_query_result_cached_document::InlineQueryResultCachedDocument, - inline_query_result_cached_gif::InlineQueryResultCachedGif, - inline_query_result_cached_mpeg4_gif::InlineQueryResultCachedMpeg4Gif, - inline_query_result_cached_photo::InlineQueryResultCachedPhoto, - inline_query_result_cached_sticker::InlineQueryResultCachedSticker, - inline_query_result_cached_video::InlineQueryResultCachedVideo, - inline_query_result_cached_voice::InlineQueryResultCachedVoice, - inline_query_result_article::InlineQueryResultArticle, - inline_query_result_audio::InlineQueryResultAudio, - inline_query_result_contact::InlineQueryResultContact, - inline_query_result_game::InlineQueryResultGame, - inline_query_result_document::InlineQueryResultDocument, - inline_query_result_gif::InlineQueryResultGif, - inline_query_result_location::InlineQueryResultLocation, - inline_query_result_mpeg4_gif::InlineQueryResultMpeg4Gif, - inline_query_result_photo::InlineQueryResultPhoto, - inline_query_result_venue::InlineQueryResultVenue, - inline_query_result_video::InlineQueryResultVideo, - inline_query_result_voice::InlineQueryResultVoice, }; mod animation; @@ -83,12 +82,14 @@ mod chat_photo; mod chosen_inline_result; mod contact; mod document; +mod file; mod force_reply; mod game; mod inline_keyboard_button; mod inline_keyboard_markup; mod input_file; mod input_media; +mod input_message_content; mod invoice; mod keyboard_button; mod label_price; @@ -118,11 +119,11 @@ mod venue; mod video; mod video_note; mod voice; -mod file; -mod input_message_content; mod inline_query; mod inline_query_result; +mod inline_query_result_article; +mod inline_query_result_audio; mod inline_query_result_cached_audio; mod inline_query_result_cached_document; mod inline_query_result_cached_gif; @@ -131,11 +132,9 @@ mod inline_query_result_cached_photo; mod inline_query_result_cached_sticker; mod inline_query_result_cached_video; mod inline_query_result_cached_voice; -mod inline_query_result_article; -mod inline_query_result_audio; mod inline_query_result_contact; -mod inline_query_result_game; mod inline_query_result_document; +mod inline_query_result_game; mod inline_query_result_gif; mod inline_query_result_location; mod inline_query_result_mpeg4_gif; diff --git a/src/core/types/photo_size.rs b/src/core/types/photo_size.rs index 8df34596..72d110df 100644 --- a/src/core/types/photo_size.rs +++ b/src/core/types/photo_size.rs @@ -24,7 +24,7 @@ mod tests { file_id: "id".to_string(), width: 320, height: 320, - file_size: Some(3452) + file_size: Some(3452), }; let actual = serde_json::from_str::(json).unwrap(); assert_eq!(actual, expected); diff --git a/src/core/types/send_invoice.rs b/src/core/types/send_invoice.rs index 10740d81..9ca27201 100644 --- a/src/core/types/send_invoice.rs +++ b/src/core/types/send_invoice.rs @@ -1,5 +1,5 @@ -use crate::core::types::{InlineKeyboardMarkup, LabeledPrice}; use crate::core::requests::ChatId; +use crate::core::types::{InlineKeyboardMarkup, LabeledPrice}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct SendInvoice { diff --git a/src/core/types/shipping_option.rs b/src/core/types/shipping_option.rs index 9a6e4e8e..b5e0c11d 100644 --- a/src/core/types/shipping_option.rs +++ b/src/core/types/shipping_option.rs @@ -20,9 +20,10 @@ mod tests { let shipping_option = ShippingOption { id: "0".to_string(), title: "Option".to_string(), - prices: vec![ - LabeledPrice { label: "Label".to_string(), amount: 60 } - ] + prices: vec![LabeledPrice { + label: "Label".to_string(), + amount: 60, + }], }; let expected = r#"{"id":"0","title":"Option","prices":[{"label":"Label","amount":60}]}"#; let actual = serde_json::to_string(&shipping_option).unwrap(); diff --git a/src/core/types/update.rs b/src/core/types/update.rs index c168d831..edb2626b 100644 --- a/src/core/types/update.rs +++ b/src/core/types/update.rs @@ -1,6 +1,4 @@ -use crate::core::types::{ - Message, ChosenInlineResult, CallbackQuery, -}; +use crate::core::types::{CallbackQuery, ChosenInlineResult, Message}; #[derive(Debug, Deserialize, PartialEq, Clone)] pub struct Update { diff --git a/src/core/types/venue.rs b/src/core/types/venue.rs index c0dcc7ee..75d26820 100644 --- a/src/core/types/venue.rs +++ b/src/core/types/venue.rs @@ -1,6 +1,5 @@ use crate::core::types::Location; - /// This object represents a venue. #[derive(Debug, Deserialize, PartialEq, Serialize, Clone)] pub struct Venue { @@ -13,7 +12,9 @@ pub struct Venue { /// 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”.) + /// 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?... -} \ No newline at end of file +} diff --git a/src/core/types/video_note.rs b/src/core/types/video_note.rs index 893664b4..711af479 100644 --- a/src/core/types/video_note.rs +++ b/src/core/types/video_note.rs @@ -1,5 +1,5 @@ -use serde::Deserialize; use crate::core::types::PhotoSize; +use serde::Deserialize; #[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)] /// This object represents a [video message](https://telegram.org/blog/video-messages-and-telescope) @@ -7,7 +7,8 @@ use crate::core::types::PhotoSize; pub struct VideoNote { /// Identifier for this file pub file_id: String, - /// Video width and height (diameter of the video message) as defined by sender + /// Video width and height (diameter of the video message) as defined by + /// sender pub length: u32, /// Duration of the video in seconds as defined by sender pub duration: u32, @@ -15,4 +16,4 @@ pub struct VideoNote { pub thumb: Option, /// Optional. File size pub file_size: Option, -} \ No newline at end of file +} diff --git a/src/core/types/voice.rs b/src/core/types/voice.rs index 9cd71c09..6a2abc8c 100644 --- a/src/core/types/voice.rs +++ b/src/core/types/voice.rs @@ -11,4 +11,4 @@ pub struct Voice { pub mime_type: Option, /// Optional. File size pub file_size: Option, -} \ No newline at end of file +}