Skip to content

Commit 7a2cbb8

Browse files
authored
Merge pull request #54 from onalante-msft/main
2 parents c2480c1 + c95ce37 commit 7a2cbb8

File tree

3 files changed

+43
-25
lines changed

3 files changed

+43
-25
lines changed

Cargo.toml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,32 @@ edition = "2018"
1212

1313
[dependencies]
1414
hex = "0.4"
15-
hyper = { version = "0.14", features = ["server", "client", "http1", "runtime"] }
16-
tokio = { version = "1.0", features = ["rt-multi-thread", "net"] }
17-
pin-project = "1.0"
18-
futures-util = "0.3"
15+
hyper = "0.14"
16+
tokio = { version = "1.0", features = ["net"] }
17+
pin-project-lite = "0.2"
1918

2019
[dev-dependencies]
21-
tokio = { version = "1.0", features = ["rt-multi-thread", "net", "macros", "io-std", "io-util"] }
20+
tokio = { version = "1.0", features = ["io-std", "io-util", "macros", "rt-multi-thread"] }
2221

2322
[features]
24-
client = []
25-
server = []
26-
default = ["client", "server"]
23+
default = []
24+
client = [
25+
"hyper/client",
26+
"hyper/http1",
27+
]
28+
server = [
29+
"hyper/http1",
30+
"hyper/server"
31+
]
32+
33+
[[example]]
34+
name = "client"
35+
required-features = ["client", "hyper/runtime"]
36+
37+
[[example]]
38+
name = "server"
39+
required-features = ["server", "hyper/runtime"]
40+
41+
[[test]]
42+
name = "server_client"
43+
required-features = ["client", "server", "hyper/runtime"]

src/client.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
use futures_util::future::BoxFuture;
21
use hex::FromHex;
32
use hyper::{
43
client::connect::{Connected, Connection},
54
service::Service,
65
Body, Client, Uri,
76
};
8-
use pin_project::pin_project;
7+
use pin_project_lite::pin_project;
98
use std::{
109
io,
10+
future::Future,
1111
path::{Path, PathBuf},
1212
pin::Pin,
1313
task::{Context, Poll},
1414
};
1515
use tokio::io::ReadBuf;
1616

17-
#[pin_project]
18-
#[derive(Debug)]
19-
pub struct UnixStream {
20-
#[pin]
21-
unix_stream: tokio::net::UnixStream,
17+
pin_project! {
18+
#[derive(Debug)]
19+
pub struct UnixStream {
20+
#[pin]
21+
unix_stream: tokio::net::UnixStream,
22+
}
2223
}
2324

2425
impl UnixStream {
@@ -80,7 +81,7 @@ impl Unpin for UnixConnector {}
8081
impl Service<Uri> for UnixConnector {
8182
type Response = UnixStream;
8283
type Error = std::io::Error;
83-
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
84+
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;
8485
fn call(&mut self, req: Uri) -> Self::Future {
8586
let fut = async move {
8687
let path = parse_socket_path(req)?;

src/server.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use hyper::server::{Builder, Server};
55
use conn::SocketIncoming;
66

77
pub(crate) mod conn {
8-
use futures_util::ready;
98
use hyper::server::accept::Accept;
10-
use pin_project::pin_project;
9+
use pin_project_lite::pin_project;
1110
use std::{
1211
io,
1312
path::Path,
@@ -16,11 +15,12 @@ pub(crate) mod conn {
1615
};
1716
use tokio::net::{UnixListener, UnixStream};
1817

19-
/// A stream of connections from binding to a socket.
20-
#[pin_project]
21-
#[derive(Debug)]
22-
pub struct SocketIncoming {
23-
listener: UnixListener,
18+
pin_project! {
19+
/// A stream of connections from binding to a socket.
20+
#[derive(Debug)]
21+
pub struct SocketIncoming {
22+
listener: UnixListener,
23+
}
2424
}
2525

2626
impl SocketIncoming {
@@ -50,8 +50,8 @@ pub(crate) mod conn {
5050
self: Pin<&mut Self>,
5151
cx: &mut Context<'_>,
5252
) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
53-
let conn = ready!(self.listener.poll_accept(cx))?.0;
54-
Poll::Ready(Some(Ok(conn)))
53+
self.listener.poll_accept(cx)?
54+
.map(|(conn, _)| Some(Ok(conn)))
5555
}
5656
}
5757

0 commit comments

Comments
 (0)