use futures::ready!
This commit is contained in:
parent
b8e3fcb79e
commit
183e30f486
@ -11,6 +11,8 @@ matrix:
|
||||
os: osx
|
||||
- rust: nightly
|
||||
os: osx
|
||||
allow_failures:
|
||||
- rust: stable
|
||||
|
||||
script:
|
||||
- cargo test
|
||||
|
@ -53,11 +53,11 @@ where
|
||||
let mut stream = Stream::new(io, session).set_eof(eof);
|
||||
|
||||
if stream.session.is_handshaking() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
|
||||
if stream.session.wants_write() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,13 +91,13 @@ where
|
||||
|
||||
// complete handshake
|
||||
if stream.session.is_handshaking() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
|
||||
// write early data (fallback)
|
||||
if !stream.session.is_early_data_accepted() {
|
||||
while *pos < data.len() {
|
||||
let len = try_ready!(stream.pin().poll_write(cx, &data[*pos..]));
|
||||
let len = futures::ready!(stream.pin().poll_write(cx, &data[*pos..]))?;
|
||||
*pos += len;
|
||||
}
|
||||
}
|
||||
@ -161,13 +161,13 @@ where
|
||||
|
||||
// complete handshake
|
||||
if stream.session.is_handshaking() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
|
||||
// write early data (fallback)
|
||||
if !stream.session.is_early_data_accepted() {
|
||||
while *pos < data.len() {
|
||||
let len = try_ready!(stream.pin().poll_write(cx, &data[*pos..]));
|
||||
let len = futures::ready!(stream.pin().poll_write(cx, &data[*pos..]))?;
|
||||
*pos += len;
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncWrite for Stream<'
|
||||
|
||||
this.session.flush()?;
|
||||
while this.session.wants_write() {
|
||||
try_ready!(this.complete_inner_io(cx, Focus::Writable));
|
||||
futures::ready!(this.complete_inner_io(cx, Focus::Writable))?;
|
||||
}
|
||||
Pin::new(&mut this.io).poll_flush(cx)
|
||||
}
|
||||
@ -236,7 +236,7 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncWrite for Stream<'
|
||||
let this = self.get_mut();
|
||||
|
||||
while this.session.wants_write() {
|
||||
try_ready!(this.complete_inner_io(cx, Focus::Writable));
|
||||
futures::ready!(this.complete_inner_io(cx, Focus::Writable))?;
|
||||
}
|
||||
Pin::new(&mut this.io).poll_close(cx)
|
||||
}
|
||||
|
@ -206,11 +206,11 @@ fn do_handshake(client: &mut ClientSession, server: &mut ServerSession, cx: &mut
|
||||
let mut stream = Stream::new(&mut good, client);
|
||||
|
||||
if stream.session.is_handshaking() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
|
||||
if stream.session.wants_write() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
|
||||
Poll::Ready(Ok(()))
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -2,16 +2,6 @@
|
||||
|
||||
#![feature(async_await)]
|
||||
|
||||
macro_rules! try_ready {
|
||||
( $e:expr ) => {
|
||||
match $e {
|
||||
Poll::Ready(Ok(output)) => output,
|
||||
Poll::Ready(Err(err)) => return Poll::Ready(Err(err.into())),
|
||||
Poll::Pending => return Poll::Pending
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod common;
|
||||
pub mod client;
|
||||
pub mod server;
|
||||
|
@ -48,11 +48,11 @@ where
|
||||
let mut stream = Stream::new(io, session).set_eof(eof);
|
||||
|
||||
if stream.session.is_handshaking() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
|
||||
if stream.session.wants_write() {
|
||||
try_ready!(stream.complete_io(cx));
|
||||
futures::ready!(stream.complete_io(cx))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user