@@ -6,8 +6,8 @@ use hyper::{
66} ;
77use pin_project_lite:: pin_project;
88use std:: {
9- io,
109 future:: Future ,
10+ io,
1111 path:: { Path , PathBuf } ,
1212 pin:: Pin ,
1313 task:: { Context , Poll } ,
@@ -23,10 +23,7 @@ pin_project! {
2323}
2424
2525impl UnixStream {
26- async fn connect < P > ( path : P ) -> std:: io:: Result < Self >
27- where
28- P : AsRef < Path > ,
29- {
26+ async fn connect ( path : impl AsRef < Path > ) -> io:: Result < Self > {
3027 let unix_stream = tokio:: net:: UnixStream :: connect ( path) . await ?;
3128 Ok ( Self { unix_stream } )
3229 }
@@ -40,9 +37,11 @@ impl tokio::io::AsyncWrite for UnixStream {
4037 ) -> Poll < Result < usize , io:: Error > > {
4138 self . project ( ) . unix_stream . poll_write ( cx, buf)
4239 }
40+
4341 fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , io:: Error > > {
4442 self . project ( ) . unix_stream . poll_flush ( cx)
4543 }
44+
4645 fn poll_shutdown ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , io:: Error > > {
4746 self . project ( ) . unix_stream . poll_shutdown ( cx)
4847 }
@@ -80,16 +79,20 @@ impl Unpin for UnixConnector {}
8079
8180impl Service < Uri > for UnixConnector {
8281 type Response = UnixStream ;
83- type Error = std:: io:: Error ;
84- type Future = Pin < Box < dyn Future < Output = Result < Self :: Response , Self :: Error > > + Send + ' static > > ;
82+ type Error = io:: Error ;
83+ #[ allow( clippy:: type_complexity) ]
84+ type Future =
85+ Pin < Box < dyn Future < Output = Result < Self :: Response , Self :: Error > > + Send + ' static > > ;
86+
8587 fn call ( & mut self , req : Uri ) -> Self :: Future {
8688 let fut = async move {
87- let path = parse_socket_path ( req) ?;
89+ let path = parse_socket_path ( & req) ?;
8890 UnixStream :: connect ( path) . await
8991 } ;
9092
9193 Box :: pin ( fut)
9294 }
95+
9396 fn poll_ready ( & mut self , _cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
9497 Poll :: Ready ( Ok ( ( ) ) )
9598 }
@@ -101,7 +104,7 @@ impl Connection for UnixStream {
101104 }
102105}
103106
104- fn parse_socket_path ( uri : Uri ) -> Result < std :: path :: PathBuf , io:: Error > {
107+ fn parse_socket_path ( uri : & Uri ) -> Result < PathBuf , io:: Error > {
105108 if uri. scheme_str ( ) != Some ( "unix" ) {
106109 return Err ( io:: Error :: new (
107110 io:: ErrorKind :: InvalidInput ,
@@ -138,6 +141,7 @@ pub trait UnixClientExt {
138141 ///
139142 /// let client = Client::unix();
140143 /// ```
144+ #[ must_use]
141145 fn unix ( ) -> Client < UnixConnector , Body > {
142146 Client :: builder ( ) . build ( UnixConnector )
143147 }
0 commit comments