From 91e0fc9e5e8d64ef5c6b661e8eb689c02ac008b8 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Mon, 15 Apr 2019 13:32:45 +0200 Subject: [PATCH 1/3] compat with new futures Signed-off-by: Yoshua Wuyts --- README.md | 10 ++++++---- src/lib.rs | 23 +++++++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3e33aef..b279f7a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ __Basic usage__ #![feature(futures_api)] use std::pin::Pin; -use std::task::{Poll, Waker}; +use std::task::{Context, Poll}; use futures::prelude::*; use async_ready::AsyncReady; use std::io; @@ -24,7 +24,7 @@ struct Fut; impl Future for Fut { type Output = (); - fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready(()) } } @@ -33,8 +33,10 @@ impl AsyncReady for Fut { type Ok = (); type Err = io::Error; - fn poll_ready(&mut self, waker: &Waker) - -> Poll> { + fn poll_ready( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll> { Poll::Ready(Ok(())) } } diff --git a/src/lib.rs b/src/lib.rs index 7f618c6..f8bc65e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,8 +30,10 @@ //! type Ok = (); //! type Err = io::Error; //! -//! fn poll_ready(&mut self, waker: &Waker) -//! -> Poll> { +//! fn poll_ready( +//! mut self: Pin<&mut Self>, +//! cx: &mut Context<'_>, +//! ) -> Poll> { //! Poll::Ready(Ok(())) //! } //! } @@ -39,7 +41,7 @@ #![feature(futures_api)] -use std::task::{Poll, Waker}; +use std::task::{Context, Poll}; /// Determine if the underlying API can be written to. pub trait AsyncWriteReady { @@ -50,7 +52,10 @@ pub trait AsyncWriteReady { type Err: std::error::Error + Send + Sync; /// Check if the underlying API can be written to. - fn poll_write_ready(&self, waker: &Waker) -> Poll>; + fn poll_write_ready( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>; } /// Determine if the underlying API can be read from. @@ -62,7 +67,10 @@ pub trait AsyncReadReady { type Err: std::error::Error + Send + Sync; /// Check if the underlying API can be read from. - fn poll_read_ready(&self, waker: &Waker) -> Poll>; + fn poll_read_ready( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>; } /// Determine if a struct is async-ready to yield futures. @@ -81,7 +89,10 @@ pub trait AsyncReady { type Err: std::error::Error + Send + Sync; /// Check if the stream can be read from. - fn poll_ready(&self, waker: &Waker) -> Poll>; + fn poll_ready( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>; } /// Extract an error from the underlying struct that isn't propagated through From 582c6c6c7a813adacb68bc541ec94dcc30d560ff Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Mon, 15 Apr 2019 13:36:35 +0200 Subject: [PATCH 2/3] fixes Signed-off-by: Yoshua Wuyts --- src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f8bc65e..0746581 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ //! #![feature(futures_api)] //! //! use std::pin::Pin; -//! use std::task::{Poll, Waker}; +//! use std::task::{Context, Poll}; //! use futures::prelude::*; //! use async_ready::AsyncReady; //! use std::io; @@ -41,6 +41,7 @@ #![feature(futures_api)] +use std::pin::Pin; use std::task::{Context, Poll}; /// Determine if the underlying API can be written to. @@ -53,7 +54,7 @@ pub trait AsyncWriteReady { /// Check if the underlying API can be written to. fn poll_write_ready( - mut self: Pin<&mut Self>, + self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll>; } @@ -68,7 +69,7 @@ pub trait AsyncReadReady { /// Check if the underlying API can be read from. fn poll_read_ready( - mut self: Pin<&mut Self>, + self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll>; } @@ -90,7 +91,7 @@ pub trait AsyncReady { /// Check if the stream can be read from. fn poll_ready( - mut self: Pin<&mut Self>, + self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll>; } From 7f6f565e34394909bc7a059aa4f26f397f187f25 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Mon, 15 Apr 2019 22:28:25 +0200 Subject: [PATCH 3/3] fix tests Signed-off-by: Yoshua Wuyts --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 517887a..e9fa9fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,4 @@ edition = "2018" [dependencies] [dev-dependencies] -futures-preview = "0.3.0-alpha.13" +futures-preview = "0.3.0-alpha.14" diff --git a/src/lib.rs b/src/lib.rs index 0746581..58aa16c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ //! //! impl Future for Fut { //! type Output = (); -//! fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll { +//! fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll { //! Poll::Ready(()) //! } //! }