@@ -56,7 +56,7 @@ use std::time::Duration;
5656
5757use bytes:: Bytes ;
5858use futures_util:: future:: { self , Either , FutureExt as _} ;
59- use pin_project_lite :: pin_project;
59+ use pin_project :: pin_project;
6060use tokio:: io:: { AsyncRead , AsyncWrite } ;
6161use tower_service:: Service ;
6262
@@ -75,23 +75,15 @@ use crate::{Body, Request, Response};
7575#[ cfg( feature = "http1" ) ]
7676type Http1Dispatcher < T , B , R > = proto:: dispatch:: Dispatcher < proto:: dispatch:: Client < B > , B , T , R > ;
7777
78- pin_project ! {
79- #[ project = ProtoClientProj ]
80- enum ProtoClient <T , B >
81- where
82- B : HttpBody ,
83- {
84- #[ cfg( feature = "http1" ) ]
85- H1 {
86- #[ pin]
87- h1: Http1Dispatcher <T , B , proto:: h1:: ClientTransaction >,
88- } ,
89- #[ cfg( feature = "http2" ) ]
90- H2 {
91- #[ pin]
92- h2: proto:: h2:: ClientTask <B >, _phantom: PhantomData <fn ( T ) >,
93- } ,
94- }
78+ #[ pin_project( project = ProtoClientProj ) ]
79+ enum ProtoClient < T , B >
80+ where
81+ B : HttpBody ,
82+ {
83+ #[ cfg( feature = "http1" ) ]
84+ H1 ( #[ pin] Http1Dispatcher < T , B , proto:: h1:: ClientTransaction > ) ,
85+ #[ cfg( feature = "http2" ) ]
86+ H2 ( #[ pin] proto:: h2:: ClientTask < B > , PhantomData < fn ( T ) > ) ,
9587}
9688
9789/// Returns a handshake future over some IO.
@@ -408,7 +400,7 @@ where
408400 pub fn into_parts ( self ) -> Parts < T > {
409401 match self . inner . expect ( "already upgraded" ) {
410402 #[ cfg( feature = "http1" ) ]
411- ProtoClient :: H1 { h1 } => {
403+ ProtoClient :: H1 ( h1 ) => {
412404 let ( io, read_buf, _) = h1. into_inner ( ) ;
413405 Parts {
414406 io,
@@ -417,7 +409,7 @@ where
417409 }
418410 }
419411 #[ cfg( feature = "http2" ) ]
420- ProtoClient :: H2 { .. } => {
412+ ProtoClient :: H2 ( .. ) => {
421413 panic ! ( "http2 cannot into_inner" ) ;
422414 }
423415 }
@@ -437,9 +429,9 @@ where
437429 pub fn poll_without_shutdown ( & mut self , cx : & mut task:: Context < ' _ > ) -> Poll < crate :: Result < ( ) > > {
438430 match * self . inner . as_mut ( ) . expect ( "already upgraded" ) {
439431 #[ cfg( feature = "http1" ) ]
440- ProtoClient :: H1 { ref mut h1 } => h1. poll_without_shutdown ( cx) ,
432+ ProtoClient :: H1 ( ref mut h1) => h1. poll_without_shutdown ( cx) ,
441433 #[ cfg( feature = "http2" ) ]
442- ProtoClient :: H2 { ref mut h2, .. } => Pin :: new ( h2) . poll ( cx) . map_ok ( |_| ( ) ) ,
434+ ProtoClient :: H2 ( ref mut h2, _ ) => Pin :: new ( h2) . poll ( cx) . map_ok ( |_| ( ) ) ,
443435 }
444436 }
445437
@@ -468,7 +460,7 @@ where
468460 proto:: Dispatched :: Shutdown => Poll :: Ready ( Ok ( ( ) ) ) ,
469461 #[ cfg( feature = "http1" ) ]
470462 proto:: Dispatched :: Upgrade ( pending) => match self . inner . take ( ) {
471- Some ( ProtoClient :: H1 { h1 } ) => {
463+ Some ( ProtoClient :: H1 ( h1 ) ) => {
472464 let ( io, buf, _) = h1. into_inner ( ) ;
473465 pending. fulfill ( Upgraded :: new ( io, buf) ) ;
474466 Poll :: Ready ( Ok ( ( ) ) )
@@ -715,17 +707,14 @@ impl Builder {
715707 }
716708 let cd = proto:: h1:: dispatch:: Client :: new ( rx) ;
717709 let dispatch = proto:: h1:: Dispatcher :: new ( cd, conn) ;
718- ProtoClient :: H1 { h1 : dispatch }
710+ ProtoClient :: H1 ( dispatch)
719711 }
720712 #[ cfg( feature = "http2" ) ]
721713 Proto :: Http2 => {
722714 let h2 =
723715 proto:: h2:: client:: handshake ( io, rx, & opts. h2_builder , opts. exec . clone ( ) )
724716 . await ?;
725- ProtoClient :: H2 {
726- h2,
727- _phantom : PhantomData ,
728- }
717+ ProtoClient :: H2 ( h2, PhantomData )
729718 }
730719 } ;
731720
@@ -779,9 +768,9 @@ where
779768 fn poll ( self : Pin < & mut Self > , cx : & mut task:: Context < ' _ > ) -> Poll < Self :: Output > {
780769 match self . project ( ) {
781770 #[ cfg( feature = "http1" ) ]
782- ProtoClientProj :: H1 { h1 } => h1 . poll ( cx) ,
771+ ProtoClientProj :: H1 ( c ) => c . poll ( cx) ,
783772 #[ cfg( feature = "http2" ) ]
784- ProtoClientProj :: H2 { h2 , .. } => h2 . poll ( cx) ,
773+ ProtoClientProj :: H2 ( c , _ ) => c . poll ( cx) ,
785774 }
786775 }
787776}
0 commit comments