mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Pin RequestFuture
This commit is contained in:
parent
9f8396f752
commit
f100bdc7ed
3 changed files with 10 additions and 3 deletions
|
@ -11,7 +11,7 @@ impl Request for GetMe {
|
|||
type ReturnValue = User;
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
use reqwest::r#async::Client;
|
||||
use reqwest::StatusCode;
|
||||
|
@ -42,7 +43,9 @@ pub trait Request {
|
|||
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?
|
||||
#[derive(Debug)]
|
||||
|
@ -65,3 +68,7 @@ pub enum ChatId {
|
|||
|
||||
pub mod get_me;
|
||||
pub mod send_message;
|
||||
|
||||
fn a() {
|
||||
use futures;
|
||||
}
|
|
@ -25,7 +25,7 @@ impl Request for SendMessage {
|
|||
type ReturnValue = Message;
|
||||
|
||||
fn send(self) -> RequestFuture<ResponseResult<Self::ReturnValue>> {
|
||||
Box::new(async move {
|
||||
Box::pin(async move {
|
||||
let params = FormBuilder::new()
|
||||
.add("chat_id", &self.chat_id)
|
||||
.add("text", &self.text)
|
||||
|
|
Loading…
Reference in a new issue