From 4c1cefefe6bd47a0c6461a1fcd51f508da6e96b3 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 12 Nov 2019 11:09:19 +0600 Subject: [PATCH] rename Factor to ServiceFactory --- actix-server/src/builder.rs | 2 +- actix-server/src/config.rs | 14 ++++---- actix-server/src/lib.rs | 7 ++-- actix-server/src/{services.rs => service.rs} | 6 ++-- actix-server/src/worker.rs | 2 +- actix-service/src/and_then.rs | 32 ++++++++--------- actix-service/src/apply.rs | 22 ++++++------ actix-service/src/apply_cfg.rs | 22 ++++++------ actix-service/src/boxed.rs | 20 +++++++---- actix-service/src/fn_service.rs | 23 ++++++------ actix-service/src/into.rs | 38 ++++++++++---------- actix-service/src/lib.rs | 22 ++++++------ actix-service/src/map.rs | 16 ++++----- actix-service/src/map_config.rs | 22 ++++++------ actix-service/src/map_err.rs | 18 +++++----- actix-service/src/map_init_err.rs | 14 ++++---- actix-service/src/pipeline.rs | 22 ++++++------ actix-service/src/then.rs | 26 +++++++------- actix-service/src/transform.rs | 18 +++++----- 19 files changed, 175 insertions(+), 171 deletions(-) rename actix-server/src/{services.rs => service.rs} (95%) diff --git a/actix-server/src/builder.rs b/actix-server/src/builder.rs index 6666f8fd..1a798c38 100644 --- a/actix-server/src/builder.rs +++ b/actix-server/src/builder.rs @@ -17,7 +17,7 @@ use tokio_timer::delay; use crate::accept::{AcceptLoop, AcceptNotify, Command}; use crate::config::{ConfiguredService, ServiceConfig}; use crate::server::{Server, ServerCommand}; -use crate::services::{InternalServiceFactory, ServiceFactory, StreamNewService}; +use crate::service::{InternalServiceFactory, ServiceFactory, StreamNewService}; // use crate::signals::{Signal, Signals}; use crate::socket::StdListener; use crate::worker::{self, Worker, WorkerAvailability, WorkerClient}; diff --git a/actix-server/src/config.rs b/actix-server/src/config.rs index 35176841..36e94a37 100644 --- a/actix-server/src/config.rs +++ b/actix-server/src/config.rs @@ -2,13 +2,13 @@ use std::collections::HashMap; use std::{fmt, io, net}; use actix_server_config::{Io, ServerConfig}; -use actix_service::{Factory, IntoFactory}; +use actix_service as actix; use futures::future::{Future, FutureExt, LocalBoxFuture}; use log::error; use tokio_net::tcp::TcpStream; use super::builder::bind_addr; -use super::services::{ +use super::service::{ BoxedServerService, InternalServiceFactory, ServerMessage, StreamService, }; use super::Token; @@ -195,8 +195,8 @@ impl ServiceRuntime { /// *ServiceConfig::bind()* or *ServiceConfig::listen()* methods. pub fn service(&mut self, name: &str, service: F) where - F: IntoFactory, - T: Factory> + 'static, + F: actix::IntoServiceFactory, + T: actix::ServiceFactory> + 'static, T::Future: 'static, T::Service: 'static, T::InitError: fmt::Debug, @@ -224,7 +224,7 @@ impl ServiceRuntime { } type BoxedNewService = Box< - dyn Factory< + dyn actix::ServiceFactory< Request = (Option, ServerMessage), Response = (), Error = (), @@ -239,9 +239,9 @@ struct ServiceFactory { inner: T, } -impl Factory for ServiceFactory +impl actix::ServiceFactory for ServiceFactory where - T: Factory>, + T: actix::ServiceFactory>, T::Future: 'static, T::Service: 'static, T::Error: 'static, diff --git a/actix-server/src/lib.rs b/actix-server/src/lib.rs index 24390859..6aefc010 100644 --- a/actix-server/src/lib.rs +++ b/actix-server/src/lib.rs @@ -5,7 +5,7 @@ mod builder; mod config; mod counter; mod server; -mod services; +mod service; // mod signals; mod socket; pub mod ssl; @@ -16,14 +16,11 @@ pub use actix_server_config::{Io, IoStream, Protocol, ServerConfig}; pub use self::builder::ServerBuilder; pub use self::config::{ServiceConfig, ServiceRuntime}; pub use self::server::Server; -pub use self::services::ServiceFactory; +pub use self::service::ServiceFactory; #[doc(hidden)] pub use self::socket::FromStream; -#[doc(hidden)] -pub use self::services::ServiceFactory as StreamServiceFactory; - /// Socket id token #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub(crate) struct Token(usize); diff --git a/actix-server/src/services.rs b/actix-server/src/service.rs similarity index 95% rename from actix-server/src/services.rs rename to actix-server/src/service.rs index d0bffadf..2a77c810 100644 --- a/actix-server/src/services.rs +++ b/actix-server/src/service.rs @@ -5,7 +5,7 @@ use std::time::Duration; use actix_rt::spawn; use actix_server_config::{Io, ServerConfig}; -use actix_service::{Factory, Service}; +use actix_service::{self as actix, Service, ServiceFactory as ActixServiceFactory}; use futures::future::{err, ok, LocalBoxFuture, Ready}; use futures::{FutureExt, TryFutureExt}; use log::error; @@ -25,7 +25,7 @@ pub(crate) enum ServerMessage { } pub trait ServiceFactory: Send + Clone + 'static { - type NewService: Factory>; + type NewService: actix::ServiceFactory>; fn create(&self) -> Self::NewService; } @@ -180,7 +180,7 @@ impl InternalServiceFactory for Box { impl ServiceFactory for F where F: Fn() -> T + Send + Clone + 'static, - T: Factory>, + T: actix::ServiceFactory>, I: FromStream, { type NewService = T; diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 94f2c3c2..a99064b6 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -14,7 +14,7 @@ use tokio_timer::{delay, Delay}; use crate::accept::AcceptNotify; use crate::counter::Counter; -use crate::services::{BoxedServerService, InternalServiceFactory, ServerMessage}; +use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage}; use crate::socket::{SocketAddr, StdStream}; use crate::Token; diff --git a/actix-service/src/and_then.rs b/actix-service/src/and_then.rs index 314c08b8..ee6d7370 100644 --- a/actix-service/src/and_then.rs +++ b/actix-service/src/and_then.rs @@ -4,7 +4,7 @@ use std::task::{Context, Poll}; use pin_project::pin_project; -use super::{Factory, Service}; +use super::{Service, ServiceFactory}; use crate::cell::Cell; /// Service for the `and_then` combinator, chaining a computation onto the end @@ -129,8 +129,8 @@ where /// `AndThenNewService` new service combinator pub struct AndThenNewService where - A: Factory, - B: Factory, + A: ServiceFactory, + B: ServiceFactory, { a: A, b: B, @@ -138,8 +138,8 @@ where impl AndThenNewService where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = A::Response, Error = A::Error, @@ -152,10 +152,10 @@ where } } -impl Factory for AndThenNewService +impl ServiceFactory for AndThenNewService where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = A::Response, Error = A::Error, @@ -178,8 +178,8 @@ where impl Clone for AndThenNewService where - A: Factory + Clone, - B: Factory + Clone, + A: ServiceFactory + Clone, + B: ServiceFactory + Clone, { fn clone(&self) -> Self { Self { @@ -192,8 +192,8 @@ where #[pin_project] pub struct AndThenNewServiceFuture where - A: Factory, - B: Factory, + A: ServiceFactory, + B: ServiceFactory, { #[pin] fut_b: B::Future, @@ -206,8 +206,8 @@ where impl AndThenNewServiceFuture where - A: Factory, - B: Factory, + A: ServiceFactory, + B: ServiceFactory, { fn new(fut_a: A::Future, fut_b: B::Future) -> Self { AndThenNewServiceFuture { @@ -221,8 +221,8 @@ where impl Future for AndThenNewServiceFuture where - A: Factory, - B: Factory, + A: ServiceFactory, + B: ServiceFactory, { type Output = Result, A::InitError>; diff --git a/actix-service/src/apply.rs b/actix-service/src/apply.rs index 03b321f8..d3e01a41 100644 --- a/actix-service/src/apply.rs +++ b/actix-service/src/apply.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; use std::pin::Pin; use std::task::{Context, Poll}; -use super::{Factory, IntoFactory, IntoService, Service}; +use super::{IntoService, IntoServiceFactory, Service, ServiceFactory}; /// Apply tranform function to a service pub fn apply_fn( @@ -24,12 +24,12 @@ where pub fn apply_fn_factory( service: U, f: F, -) -> impl Factory +) -> impl ServiceFactory where - T: Factory, + T: ServiceFactory, F: FnMut(In, &mut T::Service) -> R + Clone, R: Future>, - U: IntoFactory, + U: IntoServiceFactory, { ApplyNewService::new(service.into_factory(), f) } @@ -86,7 +86,7 @@ where /// `ApplyNewService` new service combinator struct ApplyNewService where - T: Factory, + T: ServiceFactory, { service: T, f: F, @@ -95,7 +95,7 @@ where impl ApplyNewService where - T: Factory, + T: ServiceFactory, F: FnMut(In, &mut T::Service) -> R + Clone, R: Future>, { @@ -109,9 +109,9 @@ where } } -impl Factory for ApplyNewService +impl ServiceFactory for ApplyNewService where - T: Factory, + T: ServiceFactory, F: FnMut(In, &mut T::Service) -> R + Clone, R: Future>, { @@ -132,7 +132,7 @@ where #[pin_project] struct ApplyNewServiceFuture where - T: Factory, + T: ServiceFactory, F: FnMut(In, &mut T::Service) -> R + Clone, R: Future>, { @@ -144,7 +144,7 @@ where impl ApplyNewServiceFuture where - T: Factory, + T: ServiceFactory, F: FnMut(In, &mut T::Service) -> R + Clone, R: Future>, { @@ -159,7 +159,7 @@ where impl Future for ApplyNewServiceFuture where - T: Factory, + T: ServiceFactory, F: FnMut(In, &mut T::Service) -> R + Clone, R: Future>, { diff --git a/actix-service/src/apply_cfg.rs b/actix-service/src/apply_cfg.rs index cd6a62f1..304ae1ee 100644 --- a/actix-service/src/apply_cfg.rs +++ b/actix-service/src/apply_cfg.rs @@ -7,13 +7,13 @@ use futures::ready; use pin_project::pin_project; use crate::cell::Cell; -use crate::{Factory, IntoService, Service}; +use crate::{IntoService, Service, ServiceFactory}; /// Convert `Fn(&Config, &mut Service) -> Future` fn to a NewService pub fn apply_cfg( srv: T, f: F, -) -> impl Factory< +) -> impl ServiceFactory< Config = C, Request = S::Request, Response = S::Response, @@ -39,7 +39,7 @@ where pub fn apply_cfg_factory( srv: T, f: F, -) -> impl Factory< +) -> impl ServiceFactory< Config = C, Request = S::Request, Response = S::Response, @@ -50,7 +50,7 @@ pub fn apply_cfg_factory( where C: Clone, F: FnMut(&C, &mut T::Service) -> R, - T: Factory, + T: ServiceFactory, T::InitError: From, R: Future>, S: Service, @@ -93,7 +93,7 @@ where } } -impl Factory for ApplyConfigService +impl ServiceFactory for ApplyConfigService where F: FnMut(&C, &mut T) -> R, T: Service, @@ -145,7 +145,7 @@ struct ApplyConfigNewService where C: Clone, F: FnMut(&C, &mut T::Service) -> R, - T: Factory, + T: ServiceFactory, R: Future>, S: Service, { @@ -158,7 +158,7 @@ impl Clone for ApplyConfigNewService where C: Clone, F: FnMut(&C, &mut T::Service) -> R, - T: Factory, + T: ServiceFactory, R: Future>, S: Service, { @@ -171,11 +171,11 @@ where } } -impl Factory for ApplyConfigNewService +impl ServiceFactory for ApplyConfigNewService where C: Clone, F: FnMut(&C, &mut T::Service) -> R, - T: Factory, + T: ServiceFactory, T::InitError: From, R: Future>, S: Service, @@ -206,7 +206,7 @@ struct ApplyConfigNewServiceFut where C: Clone, F: FnMut(&C, &mut T::Service) -> R, - T: Factory, + T: ServiceFactory, T::InitError: From, R: Future>, S: Service, @@ -225,7 +225,7 @@ impl Future for ApplyConfigNewServiceFut where C: Clone, F: FnMut(&C, &mut T::Service) -> R, - T: Factory, + T: ServiceFactory, T::InitError: From, R: Future>, S: Service, diff --git a/actix-service/src/boxed.rs b/actix-service/src/boxed.rs index e93c7aa4..cee4ad2b 100644 --- a/actix-service/src/boxed.rs +++ b/actix-service/src/boxed.rs @@ -7,7 +7,7 @@ use std::task::{Context, Poll}; use futures::future::{err, ok, Either, Ready}; use futures::future::{FutureExt, LocalBoxFuture}; -use crate::{Factory, Service}; +use crate::{Service, ServiceFactory}; pub type BoxedService = Box< dyn Service< @@ -28,7 +28,7 @@ pub fn factory( factory: T, ) -> BoxedNewService where - T: Factory + 'static, + T: ServiceFactory + 'static, T::Request: 'static, T::Response: 'static, T::Service: 'static, @@ -52,7 +52,7 @@ where } type Inner = Box< - dyn Factory< + dyn ServiceFactory< Config = C, Request = Req, Response = Res, @@ -63,7 +63,7 @@ type Inner = Box< >, >; -impl Factory for BoxedNewService +impl ServiceFactory for BoxedNewService where Req: 'static, Res: 'static, @@ -84,18 +84,24 @@ where } } -struct FactoryWrapper { +struct FactoryWrapper { factory: T, _t: std::marker::PhantomData, } -impl Factory for FactoryWrapper +impl ServiceFactory for FactoryWrapper where Req: 'static, Res: 'static, Err: 'static, InitErr: 'static, - T: Factory, + T: ServiceFactory< + Config = C, + Request = Req, + Response = Res, + Error = Err, + InitError = InitErr, + >, T::Future: 'static, T::Service: 'static, ::Future: 'static, diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs index 78c73fe0..3d4ca7a8 100644 --- a/actix-service/src/fn_service.rs +++ b/actix-service/src/fn_service.rs @@ -6,12 +6,13 @@ use std::task::{Context, Poll}; use futures::future::{ok, Ready}; use pin_project::pin_project; -use crate::{Factory, IntoFactory, IntoService, Service}; +use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory}; -/// Create `Factory` for function that can act as a Service +/// Create `ServiceFactory` for function that can act as a Service pub fn service_fn( f: F, -) -> impl Factory + Clone +) -> impl ServiceFactory + + Clone where F: FnMut(Req) -> Fut + Clone, Fut: Future>, @@ -19,10 +20,10 @@ where NewServiceFn::new(f) } -/// Create `Factory` for function that can produce services +/// Create `ServiceFactory` for function that can produce services pub fn service_fn_factory( f: F, -) -> impl Factory< +) -> impl ServiceFactory< Config = Cfg, Request = S::Request, Response = S::Response, @@ -38,10 +39,10 @@ where FnNewServiceNoConfig::new(f) } -/// Create `Factory` for function that can produce services with configuration +/// Create `ServiceFactory` for function that can produce services with configuration pub fn service_fn_config( f: F, -) -> impl Factory< +) -> impl ServiceFactory< Config = Cfg, Request = Srv::Request, Response = Srv::Response, @@ -143,7 +144,7 @@ where } } -impl Factory for NewServiceFn +impl ServiceFactory for NewServiceFn where F: FnMut(Req) -> Fut + Clone, Fut: Future>, @@ -184,7 +185,7 @@ where } } -impl Factory for FnNewServiceConfig +impl ServiceFactory for FnNewServiceConfig where F: Fn(&Cfg) -> Fut, Fut: Future>, @@ -252,7 +253,7 @@ where } } -impl Factory for FnNewServiceNoConfig +impl ServiceFactory for FnNewServiceNoConfig where F: Fn() -> R, R: Future>, @@ -282,7 +283,7 @@ where } } -impl IntoFactory> for F +impl IntoServiceFactory> for F where F: Fn() -> R, R: Future>, diff --git a/actix-service/src/into.rs b/actix-service/src/into.rs index b36761ad..b6b3f612 100644 --- a/actix-service/src/into.rs +++ b/actix-service/src/into.rs @@ -3,7 +3,7 @@ use std::task::{Context, Poll}; use crate::map::{Map, MapNewService}; use crate::map_err::{MapErr, MapErrNewService}; use crate::map_init_err::MapInitErr; -use crate::{Factory, IntoFactory, IntoService, Service}; +use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory}; #[inline] /// Convert object of type `U` to a service `T` @@ -17,12 +17,12 @@ where } } -pub fn into_factory(factory: F) -> FactoryMapper +pub fn into_factory(factory: F) -> ServiceFactoryMapper where - T: Factory, - F: IntoFactory, + T: ServiceFactory, + F: IntoServiceFactory, { - FactoryMapper { + ServiceFactoryMapper { factory: factory.into_factory(), } } @@ -31,7 +31,7 @@ pub struct ServiceMapper { service: T, } -pub struct FactoryMapper { +pub struct ServiceFactoryMapper { factory: T, } @@ -108,14 +108,14 @@ impl Service for ServiceMapper { } } -impl FactoryMapper { +impl ServiceFactoryMapper { /// Map this service's output to a different type, returning a new service /// of the resulting type. pub fn map( self, f: F, - ) -> FactoryMapper< - impl Factory< + ) -> ServiceFactoryMapper< + impl ServiceFactory< Config = T::Config, Request = T::Request, Response = R, @@ -127,7 +127,7 @@ impl FactoryMapper { Self: Sized, F: FnMut(T::Response) -> R + Clone, { - FactoryMapper { + ServiceFactoryMapper { factory: MapNewService::new(self.factory, f), } } @@ -136,8 +136,8 @@ impl FactoryMapper { pub fn map_err( self, f: F, - ) -> FactoryMapper< - impl Factory< + ) -> ServiceFactoryMapper< + impl ServiceFactory< Config = T::Config, Request = T::Request, Response = T::Response, @@ -149,7 +149,7 @@ impl FactoryMapper { Self: Sized, F: Fn(T::Error) -> E + Clone, { - FactoryMapper { + ServiceFactoryMapper { factory: MapErrNewService::new(self.factory, f), } } @@ -158,8 +158,8 @@ impl FactoryMapper { pub fn map_init_err( self, f: F, - ) -> FactoryMapper< - impl Factory< + ) -> ServiceFactoryMapper< + impl ServiceFactory< Config = T::Config, Request = T::Request, Response = T::Response, @@ -171,24 +171,24 @@ impl FactoryMapper { Self: Sized, F: Fn(T::InitError) -> E + Clone, { - FactoryMapper { + ServiceFactoryMapper { factory: MapInitErr::new(self.factory, f), } } } -impl Clone for FactoryMapper +impl Clone for ServiceFactoryMapper where T: Clone, { fn clone(&self) -> Self { - FactoryMapper { + ServiceFactoryMapper { factory: self.factory.clone(), } } } -impl Factory for FactoryMapper { +impl ServiceFactory for ServiceFactoryMapper { type Config = T::Config; type Request = T::Request; type Response = T::Response; diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index a79f6ebe..19067480 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -23,7 +23,7 @@ mod transform_err; pub use self::apply::{apply_fn, apply_fn_factory}; pub use self::apply_cfg::{apply_cfg, apply_cfg_factory}; pub use self::fn_service::{service_fn, service_fn_config, service_fn_factory}; -pub use self::into::{into_factory, into_service, FactoryMapper, ServiceMapper}; +pub use self::into::{into_factory, into_service, ServiceFactoryMapper, ServiceMapper}; pub use self::map_config::{map_config, unit_config, MappedConfig}; pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory}; pub use self::transform::{apply_transform, IntoTransform, Transform}; @@ -74,7 +74,7 @@ pub trait Service { /// requests on that new TCP stream. /// /// `Config` is a service factory configuration type. -pub trait Factory { +pub trait ServiceFactory { /// Requests handled by the service. type Request; @@ -158,9 +158,9 @@ where } } -impl Factory for Rc +impl ServiceFactory for Rc where - S: Factory, + S: ServiceFactory, { type Request = S::Request; type Response = S::Response; @@ -175,9 +175,9 @@ where } } -impl Factory for Arc +impl ServiceFactory for Arc where - S: Factory, + S: ServiceFactory, { type Request = S::Request; type Response = S::Response; @@ -201,10 +201,10 @@ where fn into_service(self) -> T; } -/// Trait for types that can be converted to a `Factory` -pub trait IntoFactory +/// Trait for types that can be converted to a `ServiceFactory` +pub trait IntoServiceFactory where - T: Factory, + T: ServiceFactory, { /// Convert `Self` an `ServiceFactory` fn into_factory(self) -> T; @@ -219,9 +219,9 @@ where } } -impl IntoFactory for T +impl IntoServiceFactory for T where - T: Factory, + T: ServiceFactory, { fn into_factory(self) -> T { self diff --git a/actix-service/src/map.rs b/actix-service/src/map.rs index e42ac81f..9d8cf72a 100644 --- a/actix-service/src/map.rs +++ b/actix-service/src/map.rs @@ -5,7 +5,7 @@ use std::task::{Context, Poll}; use pin_project::pin_project; -use super::{Factory, Service}; +use super::{Service, ServiceFactory}; /// Service for the `map` combinator, changing the type of a service's response. /// @@ -113,7 +113,7 @@ impl MapNewService { /// Create new `Map` new service instance pub fn new(a: A, f: F) -> Self where - A: Factory, + A: ServiceFactory, F: FnMut(A::Response) -> Res, { Self { @@ -138,9 +138,9 @@ where } } -impl Factory for MapNewService +impl ServiceFactory for MapNewService where - A: Factory, + A: ServiceFactory, F: FnMut(A::Response) -> Res + Clone, { type Request = A::Request; @@ -160,7 +160,7 @@ where #[pin_project] pub(crate) struct MapNewServiceFuture where - A: Factory, + A: ServiceFactory, F: FnMut(A::Response) -> Res, { #[pin] @@ -170,7 +170,7 @@ where impl MapNewServiceFuture where - A: Factory, + A: ServiceFactory, F: FnMut(A::Response) -> Res, { fn new(fut: A::Future, f: F) -> Self { @@ -180,7 +180,7 @@ where impl Future for MapNewServiceFuture where - A: Factory, + A: ServiceFactory, F: FnMut(A::Response) -> Res, { type Output = Result, A::InitError>; @@ -200,7 +200,7 @@ mod tests { use futures::future::{ok, Ready}; use super::*; - use crate::{IntoFactory, Service}; + use crate::{IntoServiceFactory, Service}; struct Srv; diff --git a/actix-service/src/map_config.rs b/actix-service/src/map_config.rs index e1cfbecc..ace723e4 100644 --- a/actix-service/src/map_config.rs +++ b/actix-service/src/map_config.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use super::Factory; +use super::ServiceFactory; pub enum MappedConfig<'a, T> { Ref(&'a T), @@ -11,7 +11,7 @@ pub enum MappedConfig<'a, T> { pub fn map_config( factory: T, f: F, -) -> impl Factory< +) -> impl ServiceFactory< Config = C, Request = T::Request, Response = T::Response, @@ -19,7 +19,7 @@ pub fn map_config( InitError = T::InitError, > where - T: Factory, + T: ServiceFactory, F: Fn(&C) -> MappedConfig, { MapConfig::new(factory, f) @@ -28,7 +28,7 @@ where /// Replace config with unit pub fn unit_config( new_service: T, -) -> impl Factory< +) -> impl ServiceFactory< Config = C, Request = T::Request, Response = T::Response, @@ -36,7 +36,7 @@ pub fn unit_config( InitError = T::InitError, > where - T: Factory, + T: ServiceFactory, { UnitConfig::new(new_service) } @@ -52,7 +52,7 @@ impl MapConfig { /// Create new `MapConfig` combinator pub fn new(a: A, f: F) -> Self where - A: Factory, + A: ServiceFactory, F: Fn(&C) -> MappedConfig, { Self { @@ -77,9 +77,9 @@ where } } -impl Factory for MapConfig +impl ServiceFactory for MapConfig where - A: Factory, + A: ServiceFactory, F: Fn(&C) -> MappedConfig, { type Request = A::Request; @@ -107,7 +107,7 @@ pub(crate) struct UnitConfig { impl UnitConfig where - A: Factory, + A: ServiceFactory, { /// Create new `UnitConfig` combinator pub(crate) fn new(a: A) -> Self { @@ -127,9 +127,9 @@ where } } -impl Factory for UnitConfig +impl ServiceFactory for UnitConfig where - A: Factory, + A: ServiceFactory, { type Request = A::Request; type Response = A::Response; diff --git a/actix-service/src/map_err.rs b/actix-service/src/map_err.rs index b7f2dd24..b9424455 100644 --- a/actix-service/src/map_err.rs +++ b/actix-service/src/map_err.rs @@ -5,7 +5,7 @@ use std::task::{Context, Poll}; use pin_project::pin_project; -use super::{Factory, Service}; +use super::{Service, ServiceFactory}; /// Service for the `map_err` combinator, changing the type of a service's /// error. @@ -105,7 +105,7 @@ where /// This is created by the `NewServiceExt::map_err` method. pub(crate) struct MapErrNewService where - A: Factory, + A: ServiceFactory, F: Fn(A::Error) -> E + Clone, { a: A, @@ -115,7 +115,7 @@ where impl MapErrNewService where - A: Factory, + A: ServiceFactory, F: Fn(A::Error) -> E + Clone, { /// Create new `MapErr` new service instance @@ -130,7 +130,7 @@ where impl Clone for MapErrNewService where - A: Factory + Clone, + A: ServiceFactory + Clone, F: Fn(A::Error) -> E + Clone, { fn clone(&self) -> Self { @@ -142,9 +142,9 @@ where } } -impl Factory for MapErrNewService +impl ServiceFactory for MapErrNewService where - A: Factory, + A: ServiceFactory, F: Fn(A::Error) -> E + Clone, { type Request = A::Request; @@ -164,7 +164,7 @@ where #[pin_project] pub(crate) struct MapErrNewServiceFuture where - A: Factory, + A: ServiceFactory, F: Fn(A::Error) -> E, { #[pin] @@ -174,7 +174,7 @@ where impl MapErrNewServiceFuture where - A: Factory, + A: ServiceFactory, F: Fn(A::Error) -> E, { fn new(fut: A::Future, f: F) -> Self { @@ -184,7 +184,7 @@ where impl Future for MapErrNewServiceFuture where - A: Factory, + A: ServiceFactory, F: Fn(A::Error) -> E + Clone, { type Output = Result, A::InitError>; diff --git a/actix-service/src/map_init_err.rs b/actix-service/src/map_init_err.rs index 52e870dc..36881692 100644 --- a/actix-service/src/map_init_err.rs +++ b/actix-service/src/map_init_err.rs @@ -5,7 +5,7 @@ use std::task::{Context, Poll}; use pin_project::pin_project; -use super::Factory; +use super::ServiceFactory; /// `MapInitErr` service combinator pub(crate) struct MapInitErr { @@ -16,7 +16,7 @@ pub(crate) struct MapInitErr { impl MapInitErr where - A: Factory, + A: ServiceFactory, F: Fn(A::InitError) -> E, { /// Create new `MapInitErr` combinator @@ -43,9 +43,9 @@ where } } -impl Factory for MapInitErr +impl ServiceFactory for MapInitErr where - A: Factory, + A: ServiceFactory, F: Fn(A::InitError) -> E + Clone, { type Request = A::Request; @@ -64,7 +64,7 @@ where #[pin_project] pub(crate) struct MapInitErrFuture where - A: Factory, + A: ServiceFactory, F: Fn(A::InitError) -> E, { f: F, @@ -74,7 +74,7 @@ where impl MapInitErrFuture where - A: Factory, + A: ServiceFactory, F: Fn(A::InitError) -> E, { fn new(fut: A::Future, f: F) -> Self { @@ -84,7 +84,7 @@ where impl Future for MapInitErrFuture where - A: Factory, + A: ServiceFactory, F: Fn(A::InitError) -> E, { type Output = Result; diff --git a/actix-service/src/pipeline.rs b/actix-service/src/pipeline.rs index 8e033b6c..6eefdfd4 100644 --- a/actix-service/src/pipeline.rs +++ b/actix-service/src/pipeline.rs @@ -2,7 +2,7 @@ use std::task::{Context, Poll}; use crate::and_then::{AndThen, AndThenNewService}; use crate::then::{Then, ThenNewService}; -use crate::{Factory, IntoFactory, IntoService, Service}; +use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory}; pub fn pipeline(service: F) -> Pipeline where @@ -16,8 +16,8 @@ where pub fn pipeline_factory(factory: F) -> PipelineFactory where - T: Factory, - F: IntoFactory, + T: ServiceFactory, + F: IntoServiceFactory, { PipelineFactory { factory: factory.into_factory(), @@ -106,13 +106,13 @@ pub struct PipelineFactory { factory: T, } -impl PipelineFactory { +impl PipelineFactory { /// Call another service after call to this one has resolved successfully. pub fn and_then( self, factory: U, ) -> PipelineFactory< - impl Factory< + impl ServiceFactory< Config = T::Config, Request = T::Request, Response = U::Response, @@ -122,8 +122,8 @@ impl PipelineFactory { > where Self: Sized, - F: IntoFactory, - U: Factory< + F: IntoServiceFactory, + U: ServiceFactory< Config = T::Config, Request = T::Response, Error = T::Error, @@ -145,7 +145,7 @@ impl PipelineFactory { self, factory: F, ) -> PipelineFactory< - impl Factory< + impl ServiceFactory< Config = T::Config, Request = T::Request, Response = U::Response, @@ -155,8 +155,8 @@ impl PipelineFactory { > where Self: Sized, - F: IntoFactory, - U: Factory< + F: IntoServiceFactory, + U: ServiceFactory< Config = T::Config, Request = Result, Error = T::Error, @@ -180,7 +180,7 @@ where } } -impl Factory for PipelineFactory { +impl ServiceFactory for PipelineFactory { type Config = T::Config; type Request = T::Request; type Response = T::Response; diff --git a/actix-service/src/then.rs b/actix-service/src/then.rs index bb6fb2f4..2e23adb3 100644 --- a/actix-service/src/then.rs +++ b/actix-service/src/then.rs @@ -4,7 +4,7 @@ use std::task::{Context, Poll}; use pin_project::pin_project; -use super::{Factory, Service}; +use super::{Service, ServiceFactory}; use crate::cell::Cell; /// Service for the `then` combinator, chaining a computation onto the end of @@ -134,8 +134,8 @@ pub(crate) struct ThenNewService { impl ThenNewService where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = Result, Error = A::Error, @@ -148,10 +148,10 @@ where } } -impl Factory for ThenNewService +impl ServiceFactory for ThenNewService where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = Result, Error = A::Error, @@ -188,8 +188,8 @@ where #[pin_project] pub(crate) struct ThenNewServiceFuture where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = Result, Error = A::Error, @@ -206,8 +206,8 @@ where impl ThenNewServiceFuture where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = Result, Error = A::Error, @@ -226,8 +226,8 @@ where impl Future for ThenNewServiceFuture where - A: Factory, - B: Factory< + A: ServiceFactory, + B: ServiceFactory< Config = A::Config, Request = Result, Error = A::Error, @@ -267,7 +267,7 @@ mod tests { use futures::future::{err, ok, ready, Ready}; - use crate::{pipeline, pipeline_factory, Factory, Service}; + use crate::{pipeline, pipeline_factory, Service, ServiceFactory}; #[derive(Clone)] struct Srv1(Rc>); diff --git a/actix-service/src/transform.rs b/actix-service/src/transform.rs index d2144c34..9bed3eb8 100644 --- a/actix-service/src/transform.rs +++ b/actix-service/src/transform.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use std::task::{Context, Poll}; use crate::transform_err::{TransformFromErr, TransformMapInitErr}; -use crate::{Factory, IntoFactory, Service}; +use crate::{IntoServiceFactory, Service, ServiceFactory}; use pin_project::pin_project; @@ -133,7 +133,7 @@ where pub fn apply_transform( t: F, service: U, -) -> impl Factory< +) -> impl ServiceFactory< Config = S::Config, Request = T::Request, Response = T::Response, @@ -142,10 +142,10 @@ pub fn apply_transform( InitError = S::InitError, > + Clone where - S: Factory, + S: ServiceFactory, T: Transform, F: IntoTransform, - U: IntoFactory, + U: IntoServiceFactory, { ApplyTransform::new(t.into_transform(), service.into_factory()) } @@ -158,7 +158,7 @@ pub struct ApplyTransform { impl ApplyTransform where - S: Factory, + S: ServiceFactory, T: Transform, { /// Create new `ApplyTransform` new service instance @@ -179,9 +179,9 @@ impl Clone for ApplyTransform { } } -impl Factory for ApplyTransform +impl ServiceFactory for ApplyTransform where - S: Factory, + S: ServiceFactory, T: Transform, { type Request = T::Request; @@ -204,7 +204,7 @@ where #[pin_project] pub struct ApplyTransformFuture where - S: Factory, + S: ServiceFactory, T: Transform, { #[pin] @@ -216,7 +216,7 @@ where impl Future for ApplyTransformFuture where - S: Factory, + S: ServiceFactory, T: Transform, { type Output = Result;