WebhookInfo

This commit is contained in:
RustemB 2019-09-03 22:37:29 +05:00
commit afe840cab6
3 changed files with 10 additions and 3 deletions

View file

@ -11,7 +11,7 @@ impl Request for GetMe {
type ReturnValue = User; type ReturnValue = User;
fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> { fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> {
Box::new(async move { Box::pin(async move {
network::request(&self.info.client, &self.info.token, "getMe", None).await network::request(&self.info.client, &self.info.token, "getMe", None).await
}) })
} }

View file

@ -1,4 +1,5 @@
use std::future::Future; use std::future::Future;
use std::pin::Pin;
use reqwest::r#async::Client; use reqwest::r#async::Client;
use reqwest::StatusCode; use reqwest::StatusCode;
@ -42,7 +43,9 @@ pub trait Request {
fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>>; fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>>;
} }
pub type RequestFuture<T> = Box<dyn Future<Output = T>>; pub type RequestFuture<T> = Pin<Box<dyn Future<Output = T> + Send>>;
// todo: better name? // todo: better name?
#[derive(Debug)] #[derive(Debug)]
@ -65,3 +68,7 @@ pub enum ChatId {
pub mod get_me; pub mod get_me;
pub mod send_message; pub mod send_message;
fn a() {
use futures;
}

View file

@ -25,7 +25,7 @@ impl Request for SendMessage {
type ReturnValue = Message; type ReturnValue = Message;
fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> { fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> {
Box::new(async move { Box::pin(async move {
let params = FormBuilder::new() let params = FormBuilder::new()
.add("chat_id", &self.chat_id) .add("chat_id", &self.chat_id)
.add("text", &self.text) .add("text", &self.text)