diff --git a/src/bot/api.rs b/src/bot/api.rs index 936331d0..7a43b6c1 100644 --- a/src/bot/api.rs +++ b/src/bot/api.rs @@ -2,16 +2,16 @@ use crate::{ bot::Bot, requests::{ AnswerCallbackQuery, AnswerPreCheckoutQuery, AnswerShippingQuery, - DeleteChatStickerSet, EditMessageLiveLocation, ForwardMessage, + DeleteChatPhoto, DeleteChatStickerSet, EditMessageLiveLocation, + ExportCharInviteLink, ForwardMessage, GetChat, GetChatAdministrators, GetChatMember, GetChatMembersCount, GetFile, GetMe, GetUpdates, - KickChatMember, PinChatMessage, PromoteChatMember, RestrictChatMember, - SendAnimation, SendAudio, SendChatAction, SendContact, SendDocument, - SendLocation, SendMediaGroup, SendMessage, SendPhoto, SendPoll, - SendVenue, SendVideo, SendVideoNote, SendVoice, SetChatDescription, - SetChatStickerSet, StopMessageLiveLocation, UnbanChatMember, - UnpinChatMessage, SetChatTitle, DeleteChatPhoto, SetChatPhoto, - ExportCharInviteLink, SetChatPermissions, LeaveChat, GetChatAdministrators, - GetChat, + KickChatMember, LeaveChat, PinChatMessage, PromoteChatMember, + RestrictChatMember, SendAnimation, SendAudio, SendChatAction, + SendContact, SendDocument, SendLocation, SendMediaGroup, SendMessage, + SendPhoto, SendPoll, SendVenue, SendVideo, SendVideoNote, SendVoice, + SetChatDescription, SetChatPermissions, SetChatPhoto, + SetChatStickerSet, SetChatTitle, StopMessageLiveLocation, + UnbanChatMember, UnpinChatMessage, }, types::{ChatAction, ChatId, ChatPermissions, InputFile, InputMedia}, }; @@ -330,7 +330,10 @@ impl Bot { GetChatMember::new(self, chat_id, user_id) } - pub fn get_chat_administrators<C, I>(&self, chat_id: C) -> GetChatAdministrators + pub fn get_chat_administrators<C, I>( + &self, + chat_id: C, + ) -> GetChatAdministrators where C: Into<ChatId>, { @@ -380,31 +383,21 @@ impl Bot { SetChatTitle::new(self, chat_id, title) } - pub fn delete_chat_photo<C>( - &self, - chat_id: C, - ) -> DeleteChatPhoto + pub fn delete_chat_photo<C>(&self, chat_id: C) -> DeleteChatPhoto where C: Into<ChatId>, { DeleteChatPhoto::new(self, chat_id) } - pub fn leave_chat<C>( - &self, - chat_id: C, - ) -> LeaveChat + pub fn leave_chat<C>(&self, chat_id: C) -> LeaveChat where C: Into<ChatId>, { LeaveChat::new(self, chat_id) } - pub fn set_chat_photo<C, P>( - &self, - chat_id: C, - photo: P, - ) -> SetChatPhoto + pub fn set_chat_photo<C, P>(&self, chat_id: C, photo: P) -> SetChatPhoto where C: Into<ChatId>, P: Into<InputFile>, @@ -412,10 +405,7 @@ impl Bot { SetChatPhoto::new(self, chat_id, photo) } - pub fn export_chat_invite_link<C>( - &self, - chat_id: C, - ) -> ExportCharInviteLink + pub fn export_chat_invite_link<C>(&self, chat_id: C) -> ExportCharInviteLink where C: Into<ChatId>, { diff --git a/src/requests/delete_chat_photo.rs b/src/requests/delete_chat_photo.rs index 340f61cb..f674d4f9 100644 --- a/src/requests/delete_chat_photo.rs +++ b/src/requests/delete_chat_photo.rs @@ -1,16 +1,18 @@ use async_trait::async_trait; -use crate::bot::Bot; -use crate::types::{ChatId, True}; -use crate::requests::{ResponseResult, Request}; -use crate::network; +use crate::{ + bot::Bot, + network, + requests::{Request, ResponseResult}, + types::{ChatId, True}, +}; #[derive(Debug, Clone, Serialize)] pub struct DeleteChatPhoto<'a> { #[serde(skip_serializing)] bot: &'a Bot, - chat_id: ChatId + chat_id: ChatId, } #[async_trait] @@ -28,15 +30,16 @@ impl DeleteChatPhoto<'_> { self.bot.client(), self.bot.token(), "deleteChatPhoto", - &self - ).await + &self, + ) + .await } } impl<'a> DeleteChatPhoto<'a> { pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self where - C: Into<ChatId> + C: Into<ChatId>, { Self { bot, diff --git a/src/requests/export_chat_invite_link.rs b/src/requests/export_chat_invite_link.rs index ef3140cf..dfb809b0 100644 --- a/src/requests/export_chat_invite_link.rs +++ b/src/requests/export_chat_invite_link.rs @@ -1,16 +1,18 @@ use async_trait::async_trait; -use crate::bot::Bot; -use crate::types::ChatId; -use crate::requests::{ResponseResult, Request}; -use crate::network; +use crate::{ + bot::Bot, + network, + requests::{Request, ResponseResult}, + types::ChatId, +}; #[derive(Debug, Clone, Serialize)] pub struct ExportCharInviteLink<'a> { #[serde(skip_serializing)] bot: &'a Bot, - chat_id: ChatId + chat_id: ChatId, } #[async_trait] @@ -28,15 +30,16 @@ impl ExportCharInviteLink<'_> { self.bot.client(), self.bot.token(), "exportChatInviteLink", - &self - ).await + &self, + ) + .await } } impl<'a> ExportCharInviteLink<'a> { pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self where - C: Into<ChatId> + C: Into<ChatId>, { Self { bot, @@ -64,7 +67,8 @@ mod tests { let method = ExportCharInviteLink::new(&bot, chat_id); let expected = r#"{"chat_id":123}"#; - let actual = serde_json::to_string::<ExportCharInviteLink>(&method).unwrap(); + let actual = + serde_json::to_string::<ExportCharInviteLink>(&method).unwrap(); assert_eq!(actual, expected); } } diff --git a/src/requests/get_chat_administrators.rs b/src/requests/get_chat_administrators.rs index 693a2c70..f80c63c9 100644 --- a/src/requests/get_chat_administrators.rs +++ b/src/requests/get_chat_administrators.rs @@ -6,7 +6,11 @@ use crate::{ }; use async_trait::async_trait; -/// Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned +/// Use this method to get a list of administrators in a chat. On success, +/// returns an Array of ChatMember objects that contains information about all +/// chat administrators except other bots. If the chat is a group or a +/// supergroup and no administrators were appointed, only the creator will be +/// returned #[derive(Debug, Clone, Serialize)] pub struct GetChatAdministrators<'a> { #[serde(skip_serializing)] @@ -56,5 +60,4 @@ impl<'a> GetChatAdministrators<'a> { self.chat_id = value.into(); self } - } diff --git a/src/requests/set_chat_permissions.rs b/src/requests/set_chat_permissions.rs index fe5d3c52..a7307935 100644 --- a/src/requests/set_chat_permissions.rs +++ b/src/requests/set_chat_permissions.rs @@ -1,9 +1,11 @@ use async_trait::async_trait; -use crate::bot::Bot; -use crate::types::{ChatId, ChatPermissions, True}; -use crate::requests::{ResponseResult, Request}; -use crate::network; +use crate::{ + bot::Bot, + network, + requests::{Request, ResponseResult}, + types::{ChatId, ChatPermissions, True}, +}; #[derive(Debug, Clone, Serialize)] pub struct SetChatPermissions<'a> { @@ -11,7 +13,7 @@ pub struct SetChatPermissions<'a> { bot: &'a Bot, chat_id: ChatId, - permissions: ChatPermissions + permissions: ChatPermissions, } #[async_trait] @@ -29,17 +31,14 @@ impl SetChatPermissions<'_> { self.bot.client(), self.bot.token(), "setChatPermissions", - &self - ).await + &self, + ) + .await } } impl<'a> SetChatPermissions<'a> { - pub(crate) fn new<C, CP>( - bot: &'a Bot, - chat_id: C, - permissions: CP, - ) -> Self + pub(crate) fn new<C, CP>(bot: &'a Bot, chat_id: C, permissions: CP) -> Self where C: Into<ChatId>, CP: Into<ChatPermissions>, @@ -61,7 +60,7 @@ impl<'a> SetChatPermissions<'a> { pub fn permissions<CP>(mut self, permissions: CP) -> Self where - CP: Into<ChatPermissions> + CP: Into<ChatPermissions>, { self.permissions = permissions.into(); self @@ -84,12 +83,14 @@ mod tests { can_add_web_page_previews: None, can_change_info: None, can_invite_users: None, - can_pin_messages: None + can_pin_messages: None, }; let method = SetChatPermissions::new(&bot, chat_id, permissions); - let expected = r#"{"chat_id":123,"permissions":{"can_send_messages":true}}"#; - let actual = serde_json::to_string::<SetChatPermissions>(&method).unwrap(); + let expected = + r#"{"chat_id":123,"permissions":{"can_send_messages":true}}"#; + let actual = + serde_json::to_string::<SetChatPermissions>(&method).unwrap(); assert_eq!(actual, expected); } } diff --git a/src/requests/set_chat_photo.rs b/src/requests/set_chat_photo.rs index 34236fed..6a372d1a 100644 --- a/src/requests/set_chat_photo.rs +++ b/src/requests/set_chat_photo.rs @@ -1,10 +1,11 @@ use async_trait::async_trait; -use crate::bot::Bot; -use crate::types::{ChatId, True, InputFile}; -use crate::requests::{Request, ResponseResult}; -use crate::network; -use crate::requests::form_builder::FormBuilder; +use crate::{ + bot::Bot, + network, + requests::{form_builder::FormBuilder, Request, ResponseResult}, + types::{ChatId, InputFile, True}, +}; #[derive(Debug, Clone, Serialize)] pub struct SetChatPhoto<'a> { @@ -35,16 +36,13 @@ impl SetChatPhoto<'_> { self.bot.token(), "setChatPhoto", params.build(), - ).await + ) + .await } } impl<'a> SetChatPhoto<'a> { - pub(crate) fn new<C, P>( - bot: &'a Bot, - chat_id: C, - photo: P - ) -> Self + pub(crate) fn new<C, P>(bot: &'a Bot, chat_id: C, photo: P) -> Self where C: Into<ChatId>, P: Into<InputFile>, @@ -82,7 +80,8 @@ mod tests { let bot = Bot::new("token"); let chat_id = 123; let photo_url = "https://some_url".to_string(); - let method = SetChatPhoto::new(&bot, chat_id, InputFile::Url(photo_url)); + let method = + SetChatPhoto::new(&bot, chat_id, InputFile::Url(photo_url)); let expected = r#"{"chat_id":123,"photo":"https://some_url"}"#; let actual = serde_json::to_string::<SetChatPhoto>(&method).unwrap(); diff --git a/src/requests/set_chat_title.rs b/src/requests/set_chat_title.rs index adb94576..a86f8e2b 100644 --- a/src/requests/set_chat_title.rs +++ b/src/requests/set_chat_title.rs @@ -38,14 +38,10 @@ impl SetChatTitle<'_> { } impl<'a> SetChatTitle<'a> { - pub(crate) fn new<C, T>( - bot: &'a Bot, - chat_id: C, - title: T - ) -> Self - where - C: Into<ChatId>, - T: Into<String>, + pub(crate) fn new<C, T>(bot: &'a Bot, chat_id: C, title: T) -> Self + where + C: Into<ChatId>, + T: Into<String>, { Self { bot,