12
12
//! #![feature(futures_api)]
13
13
//!
14
14
//! use std::pin::Pin;
15
- //! use std::task::{Poll, Waker };
15
+ //! use std::task::{Context, Poll };
16
16
//! use futures::prelude::*;
17
17
//! use async_ready::AsyncReady;
18
18
//! use std::io;
21
21
//!
22
22
//! impl Future for Fut {
23
23
//! type Output = ();
24
- //! fn poll(self: Pin<&mut Self>, waker : &Waker ) -> Poll<Self::Output> {
24
+ //! fn poll(self: Pin<&mut Self>, _cx : &mut Context<'_> ) -> Poll<Self::Output> {
25
25
//! Poll::Ready(())
26
26
//! }
27
27
//! }
30
30
//! type Ok = ();
31
31
//! type Err = io::Error;
32
32
//!
33
- //! fn poll_ready(&mut self, waker: &Waker)
34
- //! -> Poll<Result<Self::Ok, Self::Err>> {
33
+ //! fn poll_ready(
34
+ //! mut self: Pin<&mut Self>,
35
+ //! cx: &mut Context<'_>,
36
+ //! ) -> Poll<Result<Self::Ok, Self::Err>> {
35
37
//! Poll::Ready(Ok(()))
36
38
//! }
37
39
//! }
38
40
//! ```
39
41
40
42
#![ feature( futures_api) ]
41
43
42
- use std:: task:: { Poll , Waker } ;
44
+ use std:: pin:: Pin ;
45
+ use std:: task:: { Context , Poll } ;
43
46
44
47
/// Determine if the underlying API can be written to.
45
48
pub trait AsyncWriteReady {
@@ -50,7 +53,10 @@ pub trait AsyncWriteReady {
50
53
type Err : std:: error:: Error + Send + Sync ;
51
54
52
55
/// Check if the underlying API can be written to.
53
- fn poll_write_ready ( & self , waker : & Waker ) -> Poll < Result < Self :: Ok , Self :: Err > > ;
56
+ fn poll_write_ready (
57
+ self : Pin < & mut Self > ,
58
+ cx : & mut Context < ' _ > ,
59
+ ) -> Poll < Result < Self :: Ok , Self :: Err > > ;
54
60
}
55
61
56
62
/// Determine if the underlying API can be read from.
@@ -62,7 +68,10 @@ pub trait AsyncReadReady {
62
68
type Err : std:: error:: Error + Send + Sync ;
63
69
64
70
/// Check if the underlying API can be read from.
65
- fn poll_read_ready ( & self , waker : & Waker ) -> Poll < Result < Self :: Ok , Self :: Err > > ;
71
+ fn poll_read_ready (
72
+ self : Pin < & mut Self > ,
73
+ cx : & mut Context < ' _ > ,
74
+ ) -> Poll < Result < Self :: Ok , Self :: Err > > ;
66
75
}
67
76
68
77
/// Determine if a struct is async-ready to yield futures.
@@ -81,7 +90,10 @@ pub trait AsyncReady {
81
90
type Err : std:: error:: Error + Send + Sync ;
82
91
83
92
/// Check if the stream can be read from.
84
- fn poll_ready ( & self , waker : & Waker ) -> Poll < Result < Self :: Ok , Self :: Err > > ;
93
+ fn poll_ready (
94
+ self : Pin < & mut Self > ,
95
+ cx : & mut Context < ' _ > ,
96
+ ) -> Poll < Result < Self :: Ok , Self :: Err > > ;
85
97
}
86
98
87
99
/// Extract an error from the underlying struct that isn't propagated through
0 commit comments