From a804c9569eede0cc517cf6783ad1de9cae513084 Mon Sep 17 00:00:00 2001 From: Alex Milkov Date: Fri, 25 Dec 2020 01:53:53 -0500 Subject: [PATCH] hyper 0.13 -> 0.14, tonic 0.2 -> 1.0 --- Cargo.toml | 8 ++++---- src/lib.rs | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2109afd..2641621 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ license = "ISC" [dependencies] anyhow = "1.0" -futures-util = "0.3.1" +futures-util = "0.3" hex = "0.4" -hyper = { version = "0.13", features = ["stream"] } -tokio = { version = "0.2", features = ["uds"] } -pin-project = "0.4" +hyper = { version = "0.14", features = ["full"] } +tokio = { version = "1.0", features = ["net", "rt-multi-thread"] } +pin-project = "1.0" diff --git a/src/lib.rs b/src/lib.rs index a4e0d7f..7484f28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ use pin_project::pin_project; use std::borrow::Cow; use std::future::Future; use std::path::Path; +use tokio::io::ReadBuf; /// A type which implements `Into` for hyper's [`hyper::Uri`] type /// targetting unix domain sockets. @@ -120,16 +121,14 @@ impl hyper::server::accept::Accept for UnixConnector { type Error = Error; fn poll_accept( - mut self: Pin<&mut Self>, + self: Pin<&mut Self>, cx: &mut Context, ) -> Poll>> { - let fut = self - .0 - .accept() + self.0 + .poll_accept(cx) .map_ok(|(stream, _addr)| stream) .map_err(|e| e.into()) - .map(|f| Some(f)); - Future::poll(Box::pin(fut).as_mut(), cx) + .map(|f| Some(f)) } } @@ -160,7 +159,7 @@ macro_rules! conn_impl_fn { } impl tokio::io::AsyncRead for UDS { - conn_impl_fn!(poll_read |self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]| -> Poll> ;;); + conn_impl_fn!(poll_read |self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>| -> Poll> ;;); } impl tokio::io::AsyncWrite for UDS { @@ -235,7 +234,9 @@ mod test { std::fs::remove_file(TEST_UNIX_ADDR).unwrap_or_else(|_| ()); - let mut rt = tokio::runtime::Runtime::new()?; + let rt = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build()?; rt.block_on(async { // server let uc: UnixConnector = tokio::net::UnixListener::bind(TEST_UNIX_ADDR)