Fix the compilation errors

This commit is contained in:
Temirkhan Myrzamadi 2019-10-01 16:16:02 +06:00
parent 9a2c571b57
commit 142d65186f
8 changed files with 30 additions and 25 deletions

View file

@ -26,7 +26,8 @@ impl Bot {
/// let bot = Bot::new("TOKEN"); /// let bot = Bot::new("TOKEN");
/// let mut file = File::create("/home/waffle/Pictures/test.png").await?; /// 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?; /// bot.download_file(&file_path, &mut file).await?;
/// # Ok(()) } /// # Ok(()) }
/// ``` /// ```

View file

@ -3,7 +3,7 @@ use async_trait::async_trait;
use crate::{ use crate::{
network, network,
requests::{Request, RequestContext, ResponseResult}, requests::{Request, RequestContext, ResponseResult},
types::True types::True,
}; };
#[derive(Debug, Serialize, Clone)] #[derive(Debug, Serialize, Clone)]

View file

@ -2,7 +2,7 @@ use async_trait::async_trait;
use crate::{ use crate::{
network, network,
requests::{Request, RequestContext, ResponseResult, ChatId}, requests::{ChatId, Request, RequestContext, ResponseResult},
types::True, types::True,
}; };
@ -32,7 +32,7 @@ impl<'a> Request for KickChatMember<'a> {
type ReturnValue = True; type ReturnValue = True;
async fn send_boxed(self) -> ResponseResult<Self::ReturnValue> { async fn send_boxed(self) -> ResponseResult<Self::ReturnValue> {
self.send().await self.send().await
} }
} }

View file

@ -1,5 +1,3 @@
use std::{future::Future, pin::Pin};
use async_trait::async_trait; use async_trait::async_trait;
use reqwest::r#async::Client; use reqwest::r#async::Client;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;

View file

@ -2,8 +2,8 @@ use async_trait::async_trait;
use crate::{ use crate::{
network, network,
requests::{ChatId, RequestContext, ResponseResult, Request}, requests::{ChatId, Request, RequestContext, ResponseResult},
types::True types::True,
}; };
/// Use this method to get up to date information about the chat /// Use this method to get up to date information about the chat
@ -59,6 +59,7 @@ impl PinChatMessage<'_> {
&self.ctx.token, &self.ctx.token,
"pinChatMessage", "pinChatMessage",
&self, &self,
).await )
.await
} }
} }

View file

@ -1,9 +1,9 @@
use async_trait::async_trait;
use crate::{ use crate::{
network, network,
requests::{ChatId, Request, RequestContext, ResponseResult}, requests::{ChatId, Request, RequestContext, ResponseResult},
types::{ChatPermissions, True}, types::{ChatPermissions, True},
}; };
use async_trait::async_trait;
/// Use this method to restrict a user in a supergroup. The bot must be an /// 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 /// administrator in the supergroup for this to work and must have the

View file

@ -3,7 +3,7 @@ use async_trait::async_trait;
use crate::{ use crate::{
network, network,
requests::{ChatId, Request, RequestContext, ResponseResult}, requests::{ChatId, Request, RequestContext, ResponseResult},
types::True types::True,
}; };
///Use this method when you need to tell the user that something is happening ///Use this method when you need to tell the user that something is happening

View file

@ -1,7 +1,7 @@
use async_trait::async_trait;
use crate::network; use crate::network;
use crate::requests::{ use crate::requests::{ChatId, Request, RequestContext, ResponseResult};
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
};
/// Use this method to unban a previously kicked user in a supergroup or /// 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 /// 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, pub user_id: i32,
} }
impl<'a> Request<'a> for UnbanChatMember<'a> { #[async_trait]
impl Request for UnbanChatMember<'_> {
type ReturnValue = bool; type ReturnValue = bool;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> { async fn send_boxed(self) -> ResponseResult<Self::ReturnValue> {
Box::pin(async move { self.send().await
network::request_json( }
&self.ctx.client, }
&self.ctx.token,
"unbanChatMember", impl UnbanChatMember<'_> {
&self, pub async fn send(self) -> ResponseResult<bool> {
) network::request_json(
.await &self.ctx.client,
}) &self.ctx.token,
"unbanChatMember",
&self,
)
.await
} }
} }