@@ -60,7 +60,7 @@ where T: AsyncRead + AsyncWrite,
6060 /// The service has closed, so poll until connection is closed.
6161 GoAway {
6262 connection : Accept < T , SendBuf < B :: Item > > ,
63- error : Error < S > ,
63+ error : Error < S :: Error , S :: MakeError > ,
6464 } ,
6565
6666 /// Everything is closed up.
@@ -93,20 +93,19 @@ where B: Body,
9393}
9494
9595/// Error produced by a `Connection`.
96- pub enum Error < S >
97- where S : MakeService < ( ) , Request < RecvBody > > ,
98- {
96+ #[ derive( Debug ) ]
97+ pub enum Error < E , ME = E > {
9998 /// Error produced during the HTTP/2.0 handshake.
10099 Handshake ( h2:: Error ) ,
101100
102101 /// Error produced by the HTTP/2.0 stream
103102 Protocol ( h2:: Error ) ,
104103
105104 /// Error produced when obtaining the service
106- NewService ( S :: MakeError ) ,
105+ NewService ( ME ) ,
107106
108107 /// Error produced by the service
109- Service ( S :: Error ) ,
108+ Service ( E ) ,
110109
111110 /// Error produced when attempting to spawn a task
112111 Execute ,
@@ -205,7 +204,7 @@ where T: AsyncRead + AsyncWrite,
205204 F : Modify ,
206205{
207206 type Item = ( ) ;
208- type Error = Error < S > ;
207+ type Error = Error < S :: Error , S :: MakeError > ;
209208
210209 fn poll ( & mut self ) -> Poll < Self :: Item , Self :: Error > {
211210 // Code is in poll2 to make sure any Err returned
@@ -245,7 +244,7 @@ where T: AsyncRead + AsyncWrite,
245244 self . state = State :: Done ;
246245 }
247246
248- fn poll2 ( & mut self ) -> Poll < ( ) , Error < S > > {
247+ fn poll2 ( & mut self ) -> Poll < ( ) , Error < S :: Error , S :: MakeError > > {
249248 loop {
250249 match self . state {
251250 State :: Init ( ..) => try_ready ! ( self . poll_init( ) ) ,
@@ -264,7 +263,7 @@ where T: AsyncRead + AsyncWrite,
264263 }
265264 }
266265
267- fn poll_init ( & mut self ) -> Poll < ( ) , Error < S > > {
266+ fn poll_init ( & mut self ) -> Poll < ( ) , Error < S :: Error , S :: MakeError > > {
268267 use self :: State :: * ;
269268
270269 let ( connection, service) = match self . state {
@@ -277,7 +276,7 @@ where T: AsyncRead + AsyncWrite,
277276 Ok ( ( ) . into ( ) )
278277 }
279278
280- fn poll_main ( & mut self ) -> Poll < PollMain , Error < S > > {
279+ fn poll_main ( & mut self ) -> Poll < PollMain , Error < S :: Error , S :: MakeError > > {
281280 let error = match self . state {
282281 State :: Ready { ref mut connection, ref mut service } => loop {
283282 // Make sure the service is ready
@@ -351,7 +350,7 @@ where T: AsyncRead + AsyncWrite,
351350 }
352351 }
353352
354- fn poll_goaway ( & mut self ) -> Poll < ( ) , Error < S > > {
353+ fn poll_goaway ( & mut self ) -> Poll < ( ) , Error < S :: Error , S :: MakeError > > {
355354 match self . state {
356355 State :: GoAway { ref mut connection, .. } => {
357356 try_ready ! ( connection. poll_close( ) . map_err( Error :: Protocol ) ) ;
@@ -479,47 +478,19 @@ where T: Future<Item = Response<B>>,
479478
480479// ===== impl Error =====
481480
482- impl < S > Error < S >
483- where S : MakeService < ( ) , Request < RecvBody > > ,
484- {
485- fn from_init ( err : Either < h2:: Error , S :: MakeError > ) -> Self {
481+ impl < E , ME > Error < E , ME > {
482+ fn from_init ( err : Either < h2:: Error , ME > ) -> Self {
486483 match err {
487484 Either :: A ( err) => Error :: Handshake ( err) ,
488485 Either :: B ( err) => Error :: NewService ( err) ,
489486 }
490487 }
491488}
492489
493- impl < S > fmt:: Debug for Error < S >
494- where
495- S : MakeService < ( ) , Request < RecvBody > > ,
496- S :: MakeError : fmt:: Debug ,
497- S :: Error : fmt:: Debug ,
498- {
499- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
500- match * self {
501- Error :: Handshake ( ref why) => f. debug_tuple ( "Handshake" )
502- . field ( why)
503- . finish ( ) ,
504- Error :: Protocol ( ref why) => f. debug_tuple ( "Protocol" )
505- . field ( why)
506- . finish ( ) ,
507- Error :: NewService ( ref why) => f. debug_tuple ( "NewService" )
508- . field ( why)
509- . finish ( ) ,
510- Error :: Service ( ref why) => f. debug_tuple ( "Service" )
511- . field ( why)
512- . finish ( ) ,
513- Error :: Execute => f. debug_tuple ( "Execute" ) . finish ( ) ,
514- }
515- }
516- }
517-
518- impl < S > fmt:: Display for Error < S >
490+ impl < E , ME > fmt:: Display for Error < E , ME >
519491where
520- S : MakeService < ( ) , Request < RecvBody > > ,
521- S :: MakeError : fmt:: Display ,
522- S :: Error : fmt:: Display ,
492+ E : fmt:: Display ,
493+ ME : fmt:: Display ,
523494{
524495 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
525496 match * self {
@@ -537,11 +508,10 @@ where
537508 }
538509}
539510
540- impl < S > error:: Error for Error < S >
511+ impl < E , ME > error:: Error for Error < E , ME >
541512where
542- S : MakeService < ( ) , Request < RecvBody > > ,
543- S :: MakeError : error:: Error ,
544- S :: Error : error:: Error ,
513+ E : error:: Error ,
514+ ME : error:: Error ,
545515{
546516 fn cause ( & self ) -> Option < & error:: Error > {
547517 match * self {
0 commit comments