Skip to content
This repository was archived by the owner on Oct 9, 2019. It is now read-only.

compat with new futures #1

Merged
merged 3 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ edition = "2018"
[dependencies]

[dev-dependencies]
futures-preview = "0.3.0-alpha.13"
futures-preview = "0.3.0-alpha.14"
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +24,7 @@ struct Fut;

impl Future for Fut {
type Output = ();
fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(())
}
}
Expand All @@ -33,8 +33,10 @@ impl AsyncReady for Fut {
type Ok = ();
type Err = io::Error;

fn poll_ready(&mut self, waker: &Waker)
-> Poll<Result<Self::Ok, Self::Err>> {
fn poll_ready(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Self::Ok, Self::Err>> {
Poll::Ready(Ok(()))
}
}
Expand Down
28 changes: 20 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +21,7 @@
//!
//! impl Future for Fut {
//! type Output = ();
//! fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
//! fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
//! Poll::Ready(())
//! }
//! }
Expand All @@ -30,16 +30,19 @@
//! type Ok = ();
//! type Err = io::Error;
//!
//! fn poll_ready(&mut self, waker: &Waker)
//! -> Poll<Result<Self::Ok, Self::Err>> {
//! fn poll_ready(
//! mut self: Pin<&mut Self>,
//! cx: &mut Context<'_>,
//! ) -> Poll<Result<Self::Ok, Self::Err>> {
//! Poll::Ready(Ok(()))
//! }
//! }
//! ```

#![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 {
Expand All @@ -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<Result<Self::Ok, Self::Err>>;
fn poll_write_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Self::Ok, Self::Err>>;
}

/// Determine if the underlying API can be read from.
Expand All @@ -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<Result<Self::Ok, Self::Err>>;
fn poll_read_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Self::Ok, Self::Err>>;
}

/// Determine if a struct is async-ready to yield futures.
Expand All @@ -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<Result<Self::Ok, Self::Err>>;
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Self::Ok, Self::Err>>;
}

/// Extract an error from the underlying struct that isn't propagated through
Expand Down