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/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..58aa16c 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; @@ -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(()) //! } //! } @@ -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,8 @@ #![feature(futures_api)] -use std::task::{Poll, Waker}; +use std::pin::Pin; +use std::task::{Context, Poll}; /// Determine if the underlying API can be written to. pub trait AsyncWriteReady { @@ -50,7 +53,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( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>; } /// Determine if the underlying API can be read from. @@ -62,7 +68,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( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>; } /// Determine if a struct is async-ready to yield futures. @@ -81,7 +90,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( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>; } /// Extract an error from the underlying struct that isn't propagated through