refactor(lib): convert usage of tokio_core::io to tokio_io

This commit updates to the most recent versions (released today) of the various
Tokio libraries in use. Namely the `tokio_core::io` module has now been
deprecated in favor of an external `tokio-io` crate. This commit pulls in that
crate and uses the `AsyncRead + AsyncWrite` abstraction instead of `Io` from
tokio-core.

BREAKING CHANGE: Any external types that were using that had implemented `Io` will need to 
  implement `AsyncRead + AsyncWrite` from tokio_io.
This commit is contained in:
Alex Crichton
2017-03-17 19:31:44 -05:00
committed by Sean McArthur
parent 34509ef51a
commit 8554904dc9
11 changed files with 118 additions and 96 deletions

View File

@@ -11,8 +11,8 @@ use std::rc::Rc;
use std::time::Duration;
use futures::{Poll, Async, Future, Stream};
use relay;
use tokio::io::Io;
use futures::unsync::oneshot;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio::reactor::Handle;
use tokio_proto::BindClient;
use tokio_proto::streaming::Message;
@@ -149,12 +149,12 @@ where C: Connect,
let pool_key = Rc::new(url[..::url::Position::BeforePath].to_owned());
self.connector.connect(url)
.map(move |io| {
let (tx, rx) = relay::channel();
let (tx, rx) = oneshot::channel();
let client = HttpClient {
client_rx: RefCell::new(Some(rx)),
}.bind_client(&handle, io);
let pooled = pool.pooled(pool_key, client);
tx.complete(pooled.clone());
drop(tx.send(pooled.clone()));
pooled
})
};
@@ -207,11 +207,11 @@ impl<C, B> fmt::Debug for Client<C, B> {
type TokioClient<B> = ClientProxy<Message<http::RequestHead, B>, Message<http::ResponseHead, TokioBody>, ::Error>;
struct HttpClient<B> {
client_rx: RefCell<Option<relay::Receiver<Pooled<TokioClient<B>>>>>,
client_rx: RefCell<Option<oneshot::Receiver<Pooled<TokioClient<B>>>>>,
}
impl<T, B> ClientProto<T> for HttpClient<B>
where T: Io + 'static,
where T: AsyncRead + AsyncWrite + 'static,
B: Stream<Error=::Error> + 'static,
B::Item: AsRef<[u8]>,
{
@@ -232,12 +232,12 @@ where T: Io + 'static,
}
struct BindingClient<T, B> {
rx: relay::Receiver<Pooled<TokioClient<B>>>,
rx: oneshot::Receiver<Pooled<TokioClient<B>>>,
io: Option<T>,
}
impl<T, B> Future for BindingClient<T, B>
where T: Io + 'static,
where T: AsyncRead + AsyncWrite + 'static,
B: Stream<Error=::Error>,
B::Item: AsRef<[u8]>,
{