Update with Poll/Async changes

This commit is contained in:
Alex Crichton
2016-09-02 12:17:38 -07:00
parent 3282b3ec0d
commit 3794cf7f1d
17 changed files with 103 additions and 124 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ impl<R, W> Future for Copy<R, W>
// done with the entire transfer.
if self.pos == self.cap && self.read_done {
try_nb!(self.writer.flush());
return Poll::Ok(self.amt)
return Ok(self.amt.into())
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
use std::io::{self, Write};
use futures::{Poll, Future};
use futures::{Poll, Future, Async};
/// A future used to fully flush an I/O object.
///
@@ -33,7 +33,7 @@ impl<A> Future for Flush<A>
fn poll(&mut self) -> Poll<A, io::Error> {
try_nb!(self.a.as_mut().unwrap().flush());
Poll::Ok(self.a.take().unwrap())
Ok(Async::Ready(self.a.take().unwrap()))
}
}
+2 -2
View File
@@ -25,9 +25,9 @@ macro_rules! try_nb {
($e:expr) => (match $e {
Ok(t) => t,
Err(ref e) if e.kind() == ::std::io::ErrorKind::WouldBlock => {
return ::futures::Poll::NotReady
return Ok(::futures::Async::NotReady)
}
Err(e) => return ::futures::Poll::Err(e.into()),
Err(e) => return Err(e.into()),
})
}
+2 -2
View File
@@ -62,7 +62,7 @@ impl<A, T> Future for ReadExact<A, T>
let n = try_nb!(a.read(&mut buf[*pos..]));
*pos += n;
if n == 0 {
return Poll::Err(eof())
return Err(eof())
}
}
}
@@ -70,7 +70,7 @@ impl<A, T> Future for ReadExact<A, T>
}
match mem::replace(&mut self.state, State::Empty) {
State::Reading { a, buf, .. } => Poll::Ok((a, buf)),
State::Reading { a, buf, .. } => Ok((a, buf).into()),
State::Empty => panic!(),
}
}
+1 -1
View File
@@ -55,7 +55,7 @@ impl<A> Future for ReadToEnd<A>
}
match mem::replace(&mut self.state, State::Empty) {
State::Reading { a, buf } => Poll::Ok((a, buf)),
State::Reading { a, buf } => Ok((a, buf).into()),
State::Empty => unreachable!(),
}
}
+2 -2
View File
@@ -65,7 +65,7 @@ impl<A, T> Future for WriteAll<A, T>
let n = try_nb!(a.write(&buf[*pos..]));
*pos += n;
if n == 0 {
return Poll::Err(zero_write())
return Err(zero_write())
}
}
}
@@ -73,7 +73,7 @@ impl<A, T> Future for WriteAll<A, T>
}
match mem::replace(&mut self.state, State::Empty) {
State::Writing { a, buf, .. } => Poll::Ok((a, buf)),
State::Writing { a, buf, .. } => Ok((a, buf).into()),
State::Empty => panic!(),
}
}