diff --git a/src/h1/dispatcher.rs b/src/h1/dispatcher.rs index 0a0ed04e2..667e674c5 100644 --- a/src/h1/dispatcher.rs +++ b/src/h1/dispatcher.rs @@ -85,8 +85,9 @@ impl State { impl Dispatcher where T: AsyncRead + AsyncWrite, - S: Service>, + S: Service, S::Error: Debug, + S::Response: Into>, B: MessageBody, { /// Create http/1 dispatcher. @@ -139,8 +140,9 @@ where impl InnerDispatcher where T: AsyncRead + AsyncWrite, - S: Service>, + S: Service, S::Error: Debug, + S::Response: Into>, B: MessageBody, { fn can_read(&self) -> bool { @@ -224,7 +226,7 @@ where State::ServiceCall(mut fut) => { match fut.poll().map_err(DispatchError::Service)? { Async::Ready(res) => { - let (res, body) = res.replace_body(()); + let (res, body) = res.into().replace_body(()); Some(self.send_response(res, body)?) } Async::NotReady => { @@ -287,7 +289,7 @@ where let mut task = self.service.call(req); match task.poll().map_err(DispatchError::Service)? { Async::Ready(res) => { - let (res, body) = res.replace_body(()); + let (res, body) = res.into().replace_body(()); self.send_response(res, body) } Async::NotReady => Ok(State::ServiceCall(task)), @@ -459,8 +461,9 @@ where impl Future for Dispatcher where T: AsyncRead + AsyncWrite, - S: Service>, + S: Service, S::Error: Debug, + S::Response: Into>, B: MessageBody, { type Item = H1ServiceResult; diff --git a/src/h1/service.rs b/src/h1/service.rs index fbc0a2f0f..02a4b15d6 100644 --- a/src/h1/service.rs +++ b/src/h1/service.rs @@ -28,9 +28,10 @@ pub struct H1Service { impl H1Service where - S: NewService, Response = Response> + Clone, + S: NewService> + Clone, S::Service: Clone, S::Error: Debug, + S::Response: Into>, B: MessageBody, { /// Create new `HttpService` instance. @@ -53,9 +54,10 @@ where impl NewService for H1Service where T: AsyncRead + AsyncWrite, - S: NewService> + Clone, + S: NewService + Clone, S::Service: Clone, S::Error: Debug, + S::Response: Into>, B: MessageBody, { type Request = T; @@ -214,9 +216,10 @@ pub struct H1ServiceResponse { impl Future for H1ServiceResponse where T: AsyncRead + AsyncWrite, - S: NewService>, + S: NewService, S::Service: Clone, S::Error: Debug, + S::Response: Into>, B: MessageBody, { type Item = H1ServiceHandler; @@ -240,8 +243,9 @@ pub struct H1ServiceHandler { impl H1ServiceHandler where - S: Service> + Clone, + S: Service + Clone, S::Error: Debug, + S::Response: Into>, B: MessageBody, { fn new(cfg: ServiceConfig, srv: S) -> H1ServiceHandler { @@ -256,8 +260,9 @@ where impl Service for H1ServiceHandler where T: AsyncRead + AsyncWrite, - S: Service> + Clone, + S: Service + Clone, S::Error: Debug, + S::Response: Into>, B: MessageBody, { type Request = T; diff --git a/src/h2/dispatcher.rs b/src/h2/dispatcher.rs index 001acc560..b7339fa1d 100644 --- a/src/h2/dispatcher.rs +++ b/src/h2/dispatcher.rs @@ -50,8 +50,9 @@ pub struct Dispatcher { impl Dispatcher where T: AsyncRead + AsyncWrite, - S: Service, Response = Response> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, + S::Response: Into>, B: MessageBody + 'static, { pub fn new( @@ -91,8 +92,9 @@ where impl Future for Dispatcher where T: AsyncRead + AsyncWrite, - S: Service, Response = Response> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, + S::Response: Into>, B: MessageBody + 'static, { type Item = (); @@ -149,8 +151,9 @@ enum ServiceResponseState { impl ServiceResponse where - S: Service, Response = Response> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, + S::Response: Into>, B: MessageBody + 'static, { fn prepare_response( @@ -216,8 +219,9 @@ where impl Future for ServiceResponse where - S: Service, Response = Response> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, + S::Response: Into>, B: MessageBody + 'static, { type Item = (); @@ -228,7 +232,7 @@ where ServiceResponseState::ServiceCall(ref mut call, ref mut send) => { match call.poll() { Ok(Async::Ready(res)) => { - let (res, body) = res.replace_body(()); + let (res, body) = res.into().replace_body(()); let mut send = send.take().unwrap(); let mut length = body.length(); diff --git a/src/h2/service.rs b/src/h2/service.rs index 5759b55e2..a1526375f 100644 --- a/src/h2/service.rs +++ b/src/h2/service.rs @@ -30,9 +30,10 @@ pub struct H2Service { impl H2Service where - S: NewService, Response = Response> + Clone, + S: NewService> + Clone, S::Service: Clone + 'static, S::Error: Into + Debug + 'static, + S::Response: Into>, B: MessageBody + 'static, { /// Create new `HttpService` instance. @@ -55,9 +56,10 @@ where impl NewService for H2Service where T: AsyncRead + AsyncWrite, - S: NewService, Response = Response> + Clone, + S: NewService> + Clone, S::Service: Clone + 'static, S::Error: Into + Debug, + S::Response: Into>, B: MessageBody + 'static, { type Request = T; @@ -235,8 +237,9 @@ pub struct H2ServiceResponse { impl Future for H2ServiceResponse where T: AsyncRead + AsyncWrite, - S: NewService, Response = Response>, + S: NewService>, S::Service: Clone + 'static, + S::Response: Into>, S::Error: Into + Debug, B: MessageBody + 'static, { @@ -261,8 +264,9 @@ pub struct H2ServiceHandler { impl H2ServiceHandler where - S: Service, Response = Response> + Clone + 'static, + S: Service> + Clone + 'static, S::Error: Into + Debug, + S::Response: Into>, B: MessageBody + 'static, { fn new(cfg: ServiceConfig, srv: S) -> H2ServiceHandler { @@ -277,8 +281,9 @@ where impl Service for H2ServiceHandler where T: AsyncRead + AsyncWrite, - S: Service, Response = Response> + Clone + 'static, + S: Service> + Clone + 'static, S::Error: Into + Debug, + S::Response: Into>, B: MessageBody + 'static, { type Request = T; @@ -312,8 +317,9 @@ enum State { pub struct H2ServiceHandlerResponse where T: AsyncRead + AsyncWrite, - S: Service, Response = Response> + Clone + 'static, + S: Service> + Clone + 'static, S::Error: Into + Debug, + S::Response: Into>, B: MessageBody + 'static, { state: State, @@ -322,8 +328,9 @@ where impl Future for H2ServiceHandlerResponse where T: AsyncRead + AsyncWrite, - S: Service, Response = Response> + Clone, + S: Service> + Clone, S::Error: Into + Debug, + S::Response: Into>, B: MessageBody, { type Item = ();