diff --git a/Cargo.toml b/Cargo.toml index 86a9c29cd..1705479bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,10 +37,14 @@ session = ["cookie/secure"] ssl = ["openssl", "actix-connector/ssl"] [dependencies] -actix-service = "0.3.2" +#actix-service = "0.3.2" actix-codec = "0.1.0" -actix-connector = "0.3.0" -actix-utils = "0.3.1" +#actix-connector = "0.3.0" +#actix-utils = "0.3.1" + +actix-connector = { git="https://github.com/actix/actix-net.git" } +actix-service = { git="https://github.com/actix/actix-net.git" } +actix-utils = { git="https://github.com/actix/actix-net.git" } base64 = "0.10" backtrace = "0.3" @@ -80,7 +84,8 @@ openssl = { version="0.10", optional = true } actix-rt = "0.1.0" #actix-server = { version = "0.3.0", features=["ssl"] } actix-server = { git="https://github.com/actix/actix-net.git", features=["ssl"] } -actix-connector = { version = "0.3.0", features=["ssl"] } +#actix-connector = { version = "0.3.0", features=["ssl"] } +actix-connector = { git="https://github.com/actix/actix-net.git", features=["ssl"] } actix-http-test = { path="test-server", features=["ssl"] } env_logger = "0.6" serde_derive = "1.0" diff --git a/src/client/connector.rs b/src/client/connector.rs index ccb5dbce5..b35e6af91 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -133,11 +133,8 @@ impl Connector { /// Finish configuration process and create connector service. pub fn service( self, - ) -> impl Service< - Request = Connect, - Response = impl Connection, - Error = ConnectorError, - > + Clone { + ) -> impl Service + Clone + { #[cfg(not(feature = "ssl"))] { let connector = TimeoutService::new( @@ -314,12 +311,12 @@ mod connect_impl { Io1: AsyncRead + AsyncWrite + 'static, Io2: AsyncRead + AsyncWrite + 'static, T1: Service< - Request = Connect, + Connect, Response = (Connect, Io1, Protocol), Error = ConnectorError, >, T2: Service< - Request = Connect, + Connect, Response = (Connect, Io2, Protocol), Error = ConnectorError, >, @@ -333,12 +330,12 @@ mod connect_impl { Io1: AsyncRead + AsyncWrite + 'static, Io2: AsyncRead + AsyncWrite + 'static, T1: Service< - Request = Connect, + Connect, Response = (Connect, Io1, Protocol), Error = ConnectorError, > + Clone, T2: Service< - Request = Connect, + Connect, Response = (Connect, Io2, Protocol), Error = ConnectorError, > + Clone, @@ -351,22 +348,21 @@ mod connect_impl { } } - impl Service for InnerConnector + impl Service for InnerConnector where Io1: AsyncRead + AsyncWrite + 'static, Io2: AsyncRead + AsyncWrite + 'static, T1: Service< - Request = Connect, + Connect, Response = (Connect, Io1, Protocol), Error = ConnectorError, >, T2: Service< - Request = Connect, + Connect, Response = (Connect, Io2, Protocol), Error = ConnectorError, >, { - type Request = Connect; type Response = EitherConnection; type Error = ConnectorError; type Future = Either< @@ -401,23 +397,15 @@ mod connect_impl { pub(crate) struct InnerConnectorResponseA where Io1: AsyncRead + AsyncWrite + 'static, - T: Service< - Request = Connect, - Response = (Connect, Io1, Protocol), - Error = ConnectorError, - >, + T: Service, { - fut: as Service>::Future, + fut: as Service>::Future, _t: PhantomData, } impl Future for InnerConnectorResponseA where - T: Service< - Request = Connect, - Response = (Connect, Io1, Protocol), - Error = ConnectorError, - >, + T: Service, Io1: AsyncRead + AsyncWrite + 'static, Io2: AsyncRead + AsyncWrite + 'static, { @@ -435,23 +423,15 @@ mod connect_impl { pub(crate) struct InnerConnectorResponseB where Io2: AsyncRead + AsyncWrite + 'static, - T: Service< - Request = Connect, - Response = (Connect, Io2, Protocol), - Error = ConnectorError, - >, + T: Service, { - fut: as Service>::Future, + fut: as Service>::Future, _t: PhantomData, } impl Future for InnerConnectorResponseB where - T: Service< - Request = Connect, - Response = (Connect, Io2, Protocol), - Error = ConnectorError, - >, + T: Service, Io1: AsyncRead + AsyncWrite + 'static, Io2: AsyncRead + AsyncWrite + 'static, { diff --git a/src/client/pool.rs b/src/client/pool.rs index 188980cb3..425e89395 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -48,11 +48,7 @@ pub(crate) struct ConnectionPool( impl ConnectionPool where Io: AsyncRead + AsyncWrite + 'static, - T: Service< - Request = Connect, - Response = (Connect, Io, Protocol), - Error = ConnectorError, - >, + T: Service, { pub(crate) fn new( connector: T, @@ -88,16 +84,11 @@ where } } -impl Service for ConnectionPool +impl Service for ConnectionPool where Io: AsyncRead + AsyncWrite + 'static, - T: Service< - Request = Connect, - Response = (Connect, Io, Protocol), - Error = ConnectorError, - >, + T: Service, { - type Request = Connect; type Response = IoConnection; type Error = ConnectorError; type Future = Either< diff --git a/src/client/request.rs b/src/client/request.rs index 7e971756d..637635d0f 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -176,7 +176,7 @@ where ) -> impl Future where B: 'static, - T: Service, + T: Service, I: Connection, { let Self { head, body } = self; diff --git a/src/h1/dispatcher.rs b/src/h1/dispatcher.rs index 9ae8cd2a1..7024ce3af 100644 --- a/src/h1/dispatcher.rs +++ b/src/h1/dispatcher.rs @@ -36,14 +36,14 @@ bitflags! { } /// Dispatcher for HTTP/1.1 protocol -pub struct Dispatcher +pub struct Dispatcher + 'static, B: MessageBody> where S::Error: Debug, { inner: Option>, } -struct InnerDispatcher +struct InnerDispatcher + 'static, B: MessageBody> where S::Error: Debug, { @@ -67,13 +67,13 @@ enum DispatcherMessage { Error(Response<()>), } -enum State { +enum State, B: MessageBody> { None, ServiceCall(S::Future), SendPayload(ResponseBody), } -impl State { +impl, B: MessageBody> State { fn is_empty(&self) -> bool { if let State::None = self { true @@ -86,7 +86,7 @@ impl State { impl Dispatcher where T: AsyncRead + AsyncWrite, - S: Service + 'static, + S: Service + 'static, S::Error: Debug, S::Response: Into>, B: MessageBody, @@ -141,7 +141,7 @@ where impl InnerDispatcher where T: AsyncRead + AsyncWrite, - S: Service + 'static, + S: Service + 'static, S::Error: Debug, S::Response: Into>, B: MessageBody, @@ -464,7 +464,7 @@ where impl Future for Dispatcher where T: AsyncRead + AsyncWrite, - S: Service, + S: Service, S::Error: Debug, S::Response: Into>, B: MessageBody, diff --git a/src/h1/service.rs b/src/h1/service.rs index acc7217b0..1c4f1ae3e 100644 --- a/src/h1/service.rs +++ b/src/h1/service.rs @@ -28,14 +28,14 @@ pub struct H1Service { impl H1Service where - S: NewService, + S: NewService, S::Error: Debug, S::Response: Into>, S::Service: 'static, B: MessageBody, { /// Create new `HttpService` instance with default config. - pub fn new>(service: F) -> Self { + pub fn new>(service: F) -> Self { let cfg = ServiceConfig::new(KeepAlive::Timeout(5), 5000, 0); H1Service { @@ -46,7 +46,10 @@ where } /// Create new `HttpService` instance with config. - pub fn with_config>(cfg: ServiceConfig, service: F) -> Self { + pub fn with_config>( + cfg: ServiceConfig, + service: F, + ) -> Self { H1Service { cfg, srv: service.into_new_service(), @@ -60,16 +63,15 @@ where } } -impl NewService for H1Service +impl NewService for H1Service where T: AsyncRead + AsyncWrite, - S: NewService, + S: NewService, S::Error: Debug, S::Response: Into>, S::Service: 'static, B: MessageBody, { - type Request = T; type Response = H1ServiceResult; type Error = DispatchError; type InitError = S::InitError; @@ -101,7 +103,7 @@ pub struct H1ServiceBuilder { impl H1ServiceBuilder where - S: NewService, + S: NewService, S::Error: Debug, { /// Create instance of `ServiceConfigBuilder` @@ -199,7 +201,7 @@ where pub fn finish(self, service: F) -> H1Service where B: MessageBody, - F: IntoNewService, + F: IntoNewService, { let cfg = ServiceConfig::new( self.keep_alive, @@ -215,7 +217,7 @@ where } #[doc(hidden)] -pub struct H1ServiceResponse { +pub struct H1ServiceResponse, B> { fut: ::Future, cfg: Option, _t: PhantomData<(T, B)>, @@ -224,7 +226,7 @@ pub struct H1ServiceResponse { impl Future for H1ServiceResponse where T: AsyncRead + AsyncWrite, - S: NewService, + S: NewService, S::Service: 'static, S::Error: Debug, S::Response: Into>, @@ -251,7 +253,7 @@ pub struct H1ServiceHandler { impl H1ServiceHandler where - S: Service, + S: Service, S::Error: Debug, S::Response: Into>, B: MessageBody, @@ -265,15 +267,14 @@ where } } -impl Service for H1ServiceHandler +impl Service for H1ServiceHandler where T: AsyncRead + AsyncWrite, - S: Service, + S: Service, S::Error: Debug, S::Response: Into>, B: MessageBody, { - type Request = T; type Response = H1ServiceResult; type Error = DispatchError; type Future = Dispatcher; @@ -307,11 +308,10 @@ where } } -impl NewService for OneRequest +impl NewService for OneRequest where T: AsyncRead + AsyncWrite, { - type Request = T; type Response = (Request, Framed); type Error = ParseError; type InitError = (); @@ -333,11 +333,10 @@ pub struct OneRequestService { _t: PhantomData, } -impl Service for OneRequestService +impl Service for OneRequestService where T: AsyncRead + AsyncWrite, { - type Request = T; type Response = (Request, Framed); type Error = ParseError; type Future = OneRequestServiceResponse; diff --git a/src/h2/dispatcher.rs b/src/h2/dispatcher.rs index ea8756d27..7f5409c68 100644 --- a/src/h2/dispatcher.rs +++ b/src/h2/dispatcher.rs @@ -38,7 +38,11 @@ bitflags! { } /// Dispatcher for HTTP/2 protocol -pub struct Dispatcher { +pub struct Dispatcher< + T: AsyncRead + AsyncWrite, + S: Service> + 'static, + B: MessageBody, +> { flags: Flags, service: CloneableService, connection: Connection, @@ -51,7 +55,7 @@ pub struct Dispatcher Dispatcher where T: AsyncRead + AsyncWrite, - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, S::Response: Into>, B: MessageBody + 'static, @@ -93,7 +97,7 @@ where impl Future for Dispatcher where T: AsyncRead + AsyncWrite, - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, S::Response: Into>, B: MessageBody + 'static, @@ -139,20 +143,20 @@ where } } -struct ServiceResponse { +struct ServiceResponse>, B> { state: ServiceResponseState, config: ServiceConfig, buffer: Option, } -enum ServiceResponseState { +enum ServiceResponseState>, B> { ServiceCall(S::Future, Option>), SendPayload(SendStream, ResponseBody), } impl ServiceResponse where - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, S::Response: Into>, B: MessageBody + 'static, @@ -220,7 +224,7 @@ where impl Future for ServiceResponse where - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + fmt::Debug, S::Response: Into>, B: MessageBody + 'static, diff --git a/src/h2/service.rs b/src/h2/service.rs index 583f5edda..e225e9fcb 100644 --- a/src/h2/service.rs +++ b/src/h2/service.rs @@ -31,14 +31,14 @@ pub struct H2Service { impl H2Service where - S: NewService>, + S: NewService>, S::Service: 'static, S::Error: Into + Debug + 'static, S::Response: Into>, B: MessageBody + 'static, { /// Create new `HttpService` instance. - pub fn new>(service: F) -> Self { + pub fn new>>(service: F) -> Self { let cfg = ServiceConfig::new(KeepAlive::Timeout(5), 5000, 0); H2Service { @@ -54,16 +54,15 @@ where } } -impl NewService for H2Service +impl NewService for H2Service where T: AsyncRead + AsyncWrite, - S: NewService>, + S: NewService>, S::Service: 'static, S::Error: Into + Debug, S::Response: Into>, B: MessageBody + 'static, { - type Request = T; type Response = (); type Error = DispatchError<()>; type InitError = S::InitError; @@ -95,7 +94,7 @@ pub struct H2ServiceBuilder { impl H2ServiceBuilder where - S: NewService>, + S: NewService>, S::Service: 'static, S::Error: Into + Debug + 'static, { @@ -213,7 +212,7 @@ where pub fn finish(self, service: F) -> H2Service where B: MessageBody, - F: IntoNewService, + F: IntoNewService>, { let cfg = ServiceConfig::new( self.keep_alive, @@ -229,7 +228,7 @@ where } #[doc(hidden)] -pub struct H2ServiceResponse { +pub struct H2ServiceResponse>, B> { fut: ::Future, cfg: Option, _t: PhantomData<(T, B)>, @@ -238,7 +237,7 @@ pub struct H2ServiceResponse { impl Future for H2ServiceResponse where T: AsyncRead + AsyncWrite, - S: NewService>, + S: NewService>, S::Service: 'static, S::Response: Into>, S::Error: Into + Debug, @@ -265,7 +264,7 @@ pub struct H2ServiceHandler { impl H2ServiceHandler where - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + Debug, S::Response: Into>, B: MessageBody + 'static, @@ -279,15 +278,14 @@ where } } -impl Service for H2ServiceHandler +impl Service for H2ServiceHandler where T: AsyncRead + AsyncWrite, - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + Debug, S::Response: Into>, B: MessageBody + 'static, { - type Request = T; type Response = (); type Error = DispatchError<()>; type Future = H2ServiceHandlerResponse; @@ -310,7 +308,11 @@ where } } -enum State { +enum State< + T: AsyncRead + AsyncWrite, + S: Service> + 'static, + B: MessageBody, +> { Incoming(Dispatcher), Handshake( Option>, @@ -322,7 +324,7 @@ enum State { pub struct H2ServiceHandlerResponse where T: AsyncRead + AsyncWrite, - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + Debug, S::Response: Into>, B: MessageBody + 'static, @@ -333,7 +335,7 @@ where impl Future for H2ServiceHandlerResponse where T: AsyncRead + AsyncWrite, - S: Service> + 'static, + S: Service> + 'static, S::Error: Into + Debug, S::Response: Into>, B: MessageBody, diff --git a/src/service/senderror.rs b/src/service/senderror.rs index 44d362593..8268c6660 100644 --- a/src/service/senderror.rs +++ b/src/service/senderror.rs @@ -22,12 +22,11 @@ where } } -impl NewService for SendError +impl NewService)>> for SendError where T: AsyncRead + AsyncWrite, E: ResponseError, { - type Request = Result)>; type Response = R; type Error = (E, Framed); type InitError = (); @@ -39,12 +38,11 @@ where } } -impl Service for SendError +impl Service)>> for SendError where T: AsyncRead + AsyncWrite, E: ResponseError, { - type Request = Result)>; type Response = R; type Error = (E, Framed); type Future = Either)>, SendErrorFut>; @@ -130,12 +128,11 @@ where } } -impl NewService for SendResponse +impl NewService<(Response, Framed)> for SendResponse where T: AsyncRead + AsyncWrite, B: MessageBody, { - type Request = (Response, Framed); type Response = Framed; type Error = Error; type InitError = (); @@ -147,12 +144,11 @@ where } } -impl Service for SendResponse +impl Service<(Response, Framed)> for SendResponse where T: AsyncRead + AsyncWrite, B: MessageBody, { - type Request = (Response, Framed); type Response = Framed; type Error = Error; type Future = SendResponseFut; diff --git a/src/ws/client/service.rs b/src/ws/client/service.rs index 586873d19..c48b6e0c1 100644 --- a/src/ws/client/service.rs +++ b/src/ws/client/service.rs @@ -26,7 +26,7 @@ pub type DefaultClient = Client; /// WebSocket's client pub struct Client where - T: Service, + T: Service, T::Response: AsyncRead + AsyncWrite, { connector: T, @@ -34,7 +34,7 @@ where impl Client where - T: Service, + T: Service, T::Response: AsyncRead + AsyncWrite, { /// Create new websocket's client factory @@ -51,7 +51,7 @@ impl Default for Client { impl Clone for Client where - T: Service + Clone, + T: Service + Clone, T::Response: AsyncRead + AsyncWrite, { fn clone(&self) -> Self { @@ -61,13 +61,12 @@ where } } -impl Service for Client +impl Service for Client where - T: Service, + T: Service, T::Response: AsyncRead + AsyncWrite + 'static, T::Future: 'static, { - type Request = Connect; type Response = Framed; type Error = ClientError; type Future = Either< diff --git a/src/ws/service.rs b/src/ws/service.rs index f3b066053..bbd9f7826 100644 --- a/src/ws/service.rs +++ b/src/ws/service.rs @@ -20,8 +20,7 @@ impl Default for VerifyWebSockets { } } -impl NewService for VerifyWebSockets { - type Request = (Request, Framed); +impl NewService<(Request, Framed)> for VerifyWebSockets { type Response = (Request, Framed); type Error = (HandshakeError, Framed); type InitError = (); @@ -33,8 +32,7 @@ impl NewService for VerifyWebSockets { } } -impl Service for VerifyWebSockets { - type Request = (Request, Framed); +impl Service<(Request, Framed)> for VerifyWebSockets { type Response = (Request, Framed); type Error = (HandshakeError, Framed); type Future = FutureResult; diff --git a/src/ws/transport.rs b/src/ws/transport.rs index da7782be5..6a4f4d227 100644 --- a/src/ws/transport.rs +++ b/src/ws/transport.rs @@ -7,7 +7,7 @@ use super::{Codec, Frame, Message}; pub struct Transport where - S: Service + 'static, + S: Service + 'static, T: AsyncRead + AsyncWrite, { inner: FramedTransport, @@ -16,17 +16,17 @@ where impl Transport where T: AsyncRead + AsyncWrite, - S: Service, + S: Service, S::Future: 'static, S::Error: 'static, { - pub fn new>(io: T, service: F) -> Self { + pub fn new>(io: T, service: F) -> Self { Transport { inner: FramedTransport::new(Framed::new(io, Codec::new()), service), } } - pub fn with>(framed: Framed, service: F) -> Self { + pub fn with>(framed: Framed, service: F) -> Self { Transport { inner: FramedTransport::new(framed, service), } @@ -36,7 +36,7 @@ where impl Future for Transport where T: AsyncRead + AsyncWrite, - S: Service, + S: Service, S::Future: 'static, S::Error: 'static, { diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index df56b8f3d..6a401cc58 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -35,10 +35,12 @@ ssl = ["openssl", "actix-http/ssl", "actix-server/ssl"] actix-codec = "0.1" actix-rt = "0.1.0" actix-http = { path=".." } -actix-service = "0.3.2" +#actix-service = "0.3.2" +actix-service = { git="https://github.com/actix/actix-net.git" } #actix-server = "0.3.0" actix-server = { git="https://github.com/actix/actix-net.git" } -actix-utils = "0.3.2" +#actix-utils = "0.3.2" +actix-utils = { git="https://github.com/actix/actix-net.git" } base64 = "0.10" bytes = "0.4" diff --git a/test-server/src/lib.rs b/test-server/src/lib.rs index a13e86cf8..3afee682f 100644 --- a/test-server/src/lib.rs +++ b/test-server/src/lib.rs @@ -56,8 +56,7 @@ impl TestServer { pub fn new( factory: F, ) -> TestServerRuntime< - impl Service - + Clone, + impl Service + Clone, > { let (tx, rx) = mpsc::channel(); @@ -89,11 +88,8 @@ impl TestServer { } fn new_connector( - ) -> impl Service< - Request = Connect, - Response = impl Connection, - Error = ConnectorError, - > + Clone { + ) -> impl Service + Clone + { #[cfg(feature = "ssl")] { use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; @@ -206,7 +202,7 @@ impl TestServerRuntime { impl TestServerRuntime where - T: Service + Clone, + T: Service + Clone, T::Response: Connection, { /// Connect to websocket server at a given path