diff --git a/src/bot/download.rs b/src/bot/download.rs index b969ee52..d3c6ff69 100644 --- a/src/bot/download.rs +++ b/src/bot/download.rs @@ -26,7 +26,8 @@ impl Bot { /// let bot = Bot::new("TOKEN"); /// let mut file = File::create("/home/waffle/Pictures/test.png").await?; /// - /// let TgFile { file_path, .. } = bot.get_file("*file_id*").send_boxed().await?; + /// let TgFile { file_path, .. } = + /// bot.get_file("*file_id*").send_boxed().await?; /// bot.download_file(&file_path, &mut file).await?; /// # Ok(()) } /// ``` diff --git a/src/requests/answer_pre_checkout_query.rs b/src/requests/answer_pre_checkout_query.rs index e203bf5b..9caee1e9 100644 --- a/src/requests/answer_pre_checkout_query.rs +++ b/src/requests/answer_pre_checkout_query.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use crate::{ network, requests::{Request, RequestContext, ResponseResult}, - types::True + types::True, }; #[derive(Debug, Serialize, Clone)] diff --git a/src/requests/kick_chat_member.rs b/src/requests/kick_chat_member.rs index 0a4406ee..e30716d3 100644 --- a/src/requests/kick_chat_member.rs +++ b/src/requests/kick_chat_member.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; use crate::{ network, - requests::{Request, RequestContext, ResponseResult, ChatId}, + requests::{ChatId, Request, RequestContext, ResponseResult}, types::True, }; @@ -32,7 +32,7 @@ impl<'a> Request for KickChatMember<'a> { type ReturnValue = True; async fn send_boxed(self) -> ResponseResult { - self.send().await + self.send().await } } diff --git a/src/requests/mod.rs b/src/requests/mod.rs index 209fc99d..d0c753d8 100644 --- a/src/requests/mod.rs +++ b/src/requests/mod.rs @@ -1,5 +1,3 @@ -use std::{future::Future, pin::Pin}; - use async_trait::async_trait; use reqwest::r#async::Client; use serde::de::DeserializeOwned; diff --git a/src/requests/pin_chat_message.rs b/src/requests/pin_chat_message.rs index 6f03d7a1..d8129b59 100644 --- a/src/requests/pin_chat_message.rs +++ b/src/requests/pin_chat_message.rs @@ -2,8 +2,8 @@ use async_trait::async_trait; use crate::{ network, - requests::{ChatId, RequestContext, ResponseResult, Request}, - types::True + requests::{ChatId, Request, RequestContext, ResponseResult}, + types::True, }; /// Use this method to get up to date information about the chat @@ -59,6 +59,7 @@ impl PinChatMessage<'_> { &self.ctx.token, "pinChatMessage", &self, - ).await + ) + .await } } diff --git a/src/requests/restrict_chat_member.rs b/src/requests/restrict_chat_member.rs index cfae2ef3..a8522816 100644 --- a/src/requests/restrict_chat_member.rs +++ b/src/requests/restrict_chat_member.rs @@ -1,9 +1,9 @@ -use async_trait::async_trait; use crate::{ network, requests::{ChatId, Request, RequestContext, ResponseResult}, types::{ChatPermissions, True}, }; +use async_trait::async_trait; /// Use this method to restrict a user in a supergroup. The bot must be an /// administrator in the supergroup for this to work and must have the diff --git a/src/requests/send_chat_action.rs b/src/requests/send_chat_action.rs index 67ea4b6e..d65d7905 100644 --- a/src/requests/send_chat_action.rs +++ b/src/requests/send_chat_action.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use crate::{ network, requests::{ChatId, Request, RequestContext, ResponseResult}, - types::True + types::True, }; ///Use this method when you need to tell the user that something is happening diff --git a/src/requests/unban_chat_member.rs b/src/requests/unban_chat_member.rs index 4e4e0cd9..bd84adc8 100644 --- a/src/requests/unban_chat_member.rs +++ b/src/requests/unban_chat_member.rs @@ -1,7 +1,7 @@ +use async_trait::async_trait; + use crate::network; -use crate::requests::{ - ChatId, Request, RequestContext, RequestFuture, ResponseResult, -}; +use crate::requests::{ChatId, Request, RequestContext, ResponseResult}; /// Use this method to unban a previously kicked user in a supergroup or /// channel. The user will not return to the group or channel automatically, but @@ -18,19 +18,24 @@ pub struct UnbanChatMember<'a> { pub user_id: i32, } -impl<'a> Request<'a> for UnbanChatMember<'a> { +#[async_trait] +impl Request for UnbanChatMember<'_> { type ReturnValue = bool; - fn send(self) -> RequestFuture<'a, ResponseResult> { - Box::pin(async move { - network::request_json( - &self.ctx.client, - &self.ctx.token, - "unbanChatMember", - &self, - ) - .await - }) + async fn send_boxed(self) -> ResponseResult { + self.send().await + } +} + +impl UnbanChatMember<'_> { + pub async fn send(self) -> ResponseResult { + network::request_json( + &self.ctx.client, + &self.ctx.token, + "unbanChatMember", + &self, + ) + .await } }