rename Factor to ServiceFactory

This commit is contained in:
Nikolay Kim 2019-11-12 11:09:19 +06:00
parent 8e882f0c37
commit 4c1cefefe6
19 changed files with 175 additions and 171 deletions

View File

@ -17,7 +17,7 @@ use tokio_timer::delay;
use crate::accept::{AcceptLoop, AcceptNotify, Command}; use crate::accept::{AcceptLoop, AcceptNotify, Command};
use crate::config::{ConfiguredService, ServiceConfig}; use crate::config::{ConfiguredService, ServiceConfig};
use crate::server::{Server, ServerCommand}; use crate::server::{Server, ServerCommand};
use crate::services::{InternalServiceFactory, ServiceFactory, StreamNewService}; use crate::service::{InternalServiceFactory, ServiceFactory, StreamNewService};
// use crate::signals::{Signal, Signals}; // use crate::signals::{Signal, Signals};
use crate::socket::StdListener; use crate::socket::StdListener;
use crate::worker::{self, Worker, WorkerAvailability, WorkerClient}; use crate::worker::{self, Worker, WorkerAvailability, WorkerClient};

View File

@ -2,13 +2,13 @@ use std::collections::HashMap;
use std::{fmt, io, net}; use std::{fmt, io, net};
use actix_server_config::{Io, ServerConfig}; use actix_server_config::{Io, ServerConfig};
use actix_service::{Factory, IntoFactory}; use actix_service as actix;
use futures::future::{Future, FutureExt, LocalBoxFuture}; use futures::future::{Future, FutureExt, LocalBoxFuture};
use log::error; use log::error;
use tokio_net::tcp::TcpStream; use tokio_net::tcp::TcpStream;
use super::builder::bind_addr; use super::builder::bind_addr;
use super::services::{ use super::service::{
BoxedServerService, InternalServiceFactory, ServerMessage, StreamService, BoxedServerService, InternalServiceFactory, ServerMessage, StreamService,
}; };
use super::Token; use super::Token;
@ -195,8 +195,8 @@ impl ServiceRuntime {
/// *ServiceConfig::bind()* or *ServiceConfig::listen()* methods. /// *ServiceConfig::bind()* or *ServiceConfig::listen()* methods.
pub fn service<T, F>(&mut self, name: &str, service: F) pub fn service<T, F>(&mut self, name: &str, service: F)
where where
F: IntoFactory<T>, F: actix::IntoServiceFactory<T>,
T: Factory<Config = ServerConfig, Request = Io<TcpStream>> + 'static, T: actix::ServiceFactory<Config = ServerConfig, Request = Io<TcpStream>> + 'static,
T::Future: 'static, T::Future: 'static,
T::Service: 'static, T::Service: 'static,
T::InitError: fmt::Debug, T::InitError: fmt::Debug,
@ -224,7 +224,7 @@ impl ServiceRuntime {
} }
type BoxedNewService = Box< type BoxedNewService = Box<
dyn Factory< dyn actix::ServiceFactory<
Request = (Option<CounterGuard>, ServerMessage), Request = (Option<CounterGuard>, ServerMessage),
Response = (), Response = (),
Error = (), Error = (),
@ -239,9 +239,9 @@ struct ServiceFactory<T> {
inner: T, inner: T,
} }
impl<T> Factory for ServiceFactory<T> impl<T> actix::ServiceFactory for ServiceFactory<T>
where where
T: Factory<Config = ServerConfig, Request = Io<TcpStream>>, T: actix::ServiceFactory<Config = ServerConfig, Request = Io<TcpStream>>,
T::Future: 'static, T::Future: 'static,
T::Service: 'static, T::Service: 'static,
T::Error: 'static, T::Error: 'static,

View File

@ -5,7 +5,7 @@ mod builder;
mod config; mod config;
mod counter; mod counter;
mod server; mod server;
mod services; mod service;
// mod signals; // mod signals;
mod socket; mod socket;
pub mod ssl; pub mod ssl;
@ -16,14 +16,11 @@ pub use actix_server_config::{Io, IoStream, Protocol, ServerConfig};
pub use self::builder::ServerBuilder; pub use self::builder::ServerBuilder;
pub use self::config::{ServiceConfig, ServiceRuntime}; pub use self::config::{ServiceConfig, ServiceRuntime};
pub use self::server::Server; pub use self::server::Server;
pub use self::services::ServiceFactory; pub use self::service::ServiceFactory;
#[doc(hidden)] #[doc(hidden)]
pub use self::socket::FromStream; pub use self::socket::FromStream;
#[doc(hidden)]
pub use self::services::ServiceFactory as StreamServiceFactory;
/// Socket id token /// Socket id token
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub(crate) struct Token(usize); pub(crate) struct Token(usize);

View File

@ -5,7 +5,7 @@ use std::time::Duration;
use actix_rt::spawn; use actix_rt::spawn;
use actix_server_config::{Io, ServerConfig}; 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::future::{err, ok, LocalBoxFuture, Ready};
use futures::{FutureExt, TryFutureExt}; use futures::{FutureExt, TryFutureExt};
use log::error; use log::error;
@ -25,7 +25,7 @@ pub(crate) enum ServerMessage {
} }
pub trait ServiceFactory<Stream: FromStream>: Send + Clone + 'static { pub trait ServiceFactory<Stream: FromStream>: Send + Clone + 'static {
type NewService: Factory<Config = ServerConfig, Request = Io<Stream>>; type NewService: actix::ServiceFactory<Config = ServerConfig, Request = Io<Stream>>;
fn create(&self) -> Self::NewService; fn create(&self) -> Self::NewService;
} }
@ -180,7 +180,7 @@ impl InternalServiceFactory for Box<dyn InternalServiceFactory> {
impl<F, T, I> ServiceFactory<I> for F impl<F, T, I> ServiceFactory<I> for F
where where
F: Fn() -> T + Send + Clone + 'static, F: Fn() -> T + Send + Clone + 'static,
T: Factory<Config = ServerConfig, Request = Io<I>>, T: actix::ServiceFactory<Config = ServerConfig, Request = Io<I>>,
I: FromStream, I: FromStream,
{ {
type NewService = T; type NewService = T;

View File

@ -14,7 +14,7 @@ use tokio_timer::{delay, Delay};
use crate::accept::AcceptNotify; use crate::accept::AcceptNotify;
use crate::counter::Counter; use crate::counter::Counter;
use crate::services::{BoxedServerService, InternalServiceFactory, ServerMessage}; use crate::service::{BoxedServerService, InternalServiceFactory, ServerMessage};
use crate::socket::{SocketAddr, StdStream}; use crate::socket::{SocketAddr, StdStream};
use crate::Token; use crate::Token;

View File

@ -4,7 +4,7 @@ use std::task::{Context, Poll};
use pin_project::pin_project; use pin_project::pin_project;
use super::{Factory, Service}; use super::{Service, ServiceFactory};
use crate::cell::Cell; use crate::cell::Cell;
/// Service for the `and_then` combinator, chaining a computation onto the end /// Service for the `and_then` combinator, chaining a computation onto the end
@ -129,8 +129,8 @@ where
/// `AndThenNewService` new service combinator /// `AndThenNewService` new service combinator
pub struct AndThenNewService<A, B> pub struct AndThenNewService<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory, B: ServiceFactory,
{ {
a: A, a: A,
b: B, b: B,
@ -138,8 +138,8 @@ where
impl<A, B> AndThenNewService<A, B> impl<A, B> AndThenNewService<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = A::Response, Request = A::Response,
Error = A::Error, Error = A::Error,
@ -152,10 +152,10 @@ where
} }
} }
impl<A, B> Factory for AndThenNewService<A, B> impl<A, B> ServiceFactory for AndThenNewService<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = A::Response, Request = A::Response,
Error = A::Error, Error = A::Error,
@ -178,8 +178,8 @@ where
impl<A, B> Clone for AndThenNewService<A, B> impl<A, B> Clone for AndThenNewService<A, B>
where where
A: Factory + Clone, A: ServiceFactory + Clone,
B: Factory + Clone, B: ServiceFactory + Clone,
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
@ -192,8 +192,8 @@ where
#[pin_project] #[pin_project]
pub struct AndThenNewServiceFuture<A, B> pub struct AndThenNewServiceFuture<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory<Request = A::Response>, B: ServiceFactory<Request = A::Response>,
{ {
#[pin] #[pin]
fut_b: B::Future, fut_b: B::Future,
@ -206,8 +206,8 @@ where
impl<A, B> AndThenNewServiceFuture<A, B> impl<A, B> AndThenNewServiceFuture<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory<Request = A::Response>, B: ServiceFactory<Request = A::Response>,
{ {
fn new(fut_a: A::Future, fut_b: B::Future) -> Self { fn new(fut_a: A::Future, fut_b: B::Future) -> Self {
AndThenNewServiceFuture { AndThenNewServiceFuture {
@ -221,8 +221,8 @@ where
impl<A, B> Future for AndThenNewServiceFuture<A, B> impl<A, B> Future for AndThenNewServiceFuture<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory<Request = A::Response, Error = A::Error, InitError = A::InitError>, B: ServiceFactory<Request = A::Response, Error = A::Error, InitError = A::InitError>,
{ {
type Output = Result<AndThen<A::Service, B::Service>, A::InitError>; type Output = Result<AndThen<A::Service, B::Service>, A::InitError>;

View File

@ -4,7 +4,7 @@ use std::marker::PhantomData;
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use super::{Factory, IntoFactory, IntoService, Service}; use super::{IntoService, IntoServiceFactory, Service, ServiceFactory};
/// Apply tranform function to a service /// Apply tranform function to a service
pub fn apply_fn<T, F, R, In, Out, Err, U>( pub fn apply_fn<T, F, R, In, Out, Err, U>(
@ -24,12 +24,12 @@ where
pub fn apply_fn_factory<T, F, R, In, Out, Err, U>( pub fn apply_fn_factory<T, F, R, In, Out, Err, U>(
service: U, service: U,
f: F, f: F,
) -> impl Factory<Request = In, Response = Out, Error = Err> ) -> impl ServiceFactory<Request = In, Response = Out, Error = Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
U: IntoFactory<T>, U: IntoServiceFactory<T>,
{ {
ApplyNewService::new(service.into_factory(), f) ApplyNewService::new(service.into_factory(), f)
} }
@ -86,7 +86,7 @@ where
/// `ApplyNewService` new service combinator /// `ApplyNewService` new service combinator
struct ApplyNewService<T, F, R, In, Out, Err> struct ApplyNewService<T, F, R, In, Out, Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
{ {
service: T, service: T,
f: F, f: F,
@ -95,7 +95,7 @@ where
impl<T, F, R, In, Out, Err> ApplyNewService<T, F, R, In, Out, Err> impl<T, F, R, In, Out, Err> ApplyNewService<T, F, R, In, Out, Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
{ {
@ -109,9 +109,9 @@ where
} }
} }
impl<T, F, R, In, Out, Err> Factory for ApplyNewService<T, F, R, In, Out, Err> impl<T, F, R, In, Out, Err> ServiceFactory for ApplyNewService<T, F, R, In, Out, Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
{ {
@ -132,7 +132,7 @@ where
#[pin_project] #[pin_project]
struct ApplyNewServiceFuture<T, F, R, In, Out, Err> struct ApplyNewServiceFuture<T, F, R, In, Out, Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
{ {
@ -144,7 +144,7 @@ where
impl<T, F, R, In, Out, Err> ApplyNewServiceFuture<T, F, R, In, Out, Err> impl<T, F, R, In, Out, Err> ApplyNewServiceFuture<T, F, R, In, Out, Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
{ {
@ -159,7 +159,7 @@ where
impl<T, F, R, In, Out, Err> Future for ApplyNewServiceFuture<T, F, R, In, Out, Err> impl<T, F, R, In, Out, Err> Future for ApplyNewServiceFuture<T, F, R, In, Out, Err>
where where
T: Factory<Error = Err>, T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone, F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>, R: Future<Output = Result<Out, Err>>,
{ {

View File

@ -7,13 +7,13 @@ use futures::ready;
use pin_project::pin_project; use pin_project::pin_project;
use crate::cell::Cell; use crate::cell::Cell;
use crate::{Factory, IntoService, Service}; use crate::{IntoService, Service, ServiceFactory};
/// Convert `Fn(&Config, &mut Service) -> Future<Service>` fn to a NewService /// Convert `Fn(&Config, &mut Service) -> Future<Service>` fn to a NewService
pub fn apply_cfg<F, C, T, R, S, E>( pub fn apply_cfg<F, C, T, R, S, E>(
srv: T, srv: T,
f: F, f: F,
) -> impl Factory< ) -> impl ServiceFactory<
Config = C, Config = C,
Request = S::Request, Request = S::Request,
Response = S::Response, Response = S::Response,
@ -39,7 +39,7 @@ where
pub fn apply_cfg_factory<F, C, T, R, S>( pub fn apply_cfg_factory<F, C, T, R, S>(
srv: T, srv: T,
f: F, f: F,
) -> impl Factory< ) -> impl ServiceFactory<
Config = C, Config = C,
Request = S::Request, Request = S::Request,
Response = S::Response, Response = S::Response,
@ -50,7 +50,7 @@ pub fn apply_cfg_factory<F, C, T, R, S>(
where where
C: Clone, C: Clone,
F: FnMut(&C, &mut T::Service) -> R, F: FnMut(&C, &mut T::Service) -> R,
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>, T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,
@ -93,7 +93,7 @@ where
} }
} }
impl<F, C, T, R, S, E> Factory for ApplyConfigService<F, C, T, R, S, E> impl<F, C, T, R, S, E> ServiceFactory for ApplyConfigService<F, C, T, R, S, E>
where where
F: FnMut(&C, &mut T) -> R, F: FnMut(&C, &mut T) -> R,
T: Service, T: Service,
@ -145,7 +145,7 @@ struct ApplyConfigNewService<F, C, T, R, S>
where where
C: Clone, C: Clone,
F: FnMut(&C, &mut T::Service) -> R, F: FnMut(&C, &mut T::Service) -> R,
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,
{ {
@ -158,7 +158,7 @@ impl<F, C, T, R, S> Clone for ApplyConfigNewService<F, C, T, R, S>
where where
C: Clone, C: Clone,
F: FnMut(&C, &mut T::Service) -> R, F: FnMut(&C, &mut T::Service) -> R,
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,
{ {
@ -171,11 +171,11 @@ where
} }
} }
impl<F, C, T, R, S> Factory for ApplyConfigNewService<F, C, T, R, S> impl<F, C, T, R, S> ServiceFactory for ApplyConfigNewService<F, C, T, R, S>
where where
C: Clone, C: Clone,
F: FnMut(&C, &mut T::Service) -> R, F: FnMut(&C, &mut T::Service) -> R,
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>, T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,
@ -206,7 +206,7 @@ struct ApplyConfigNewServiceFut<F, C, T, R, S>
where where
C: Clone, C: Clone,
F: FnMut(&C, &mut T::Service) -> R, F: FnMut(&C, &mut T::Service) -> R,
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>, T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,
@ -225,7 +225,7 @@ impl<F, C, T, R, S> Future for ApplyConfigNewServiceFut<F, C, T, R, S>
where where
C: Clone, C: Clone,
F: FnMut(&C, &mut T::Service) -> R, F: FnMut(&C, &mut T::Service) -> R,
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>, T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>, R: Future<Output = Result<S, T::InitError>>,
S: Service, S: Service,

View File

@ -7,7 +7,7 @@ use std::task::{Context, Poll};
use futures::future::{err, ok, Either, Ready}; use futures::future::{err, ok, Either, Ready};
use futures::future::{FutureExt, LocalBoxFuture}; use futures::future::{FutureExt, LocalBoxFuture};
use crate::{Factory, Service}; use crate::{Service, ServiceFactory};
pub type BoxedService<Req, Res, Err> = Box< pub type BoxedService<Req, Res, Err> = Box<
dyn Service< dyn Service<
@ -28,7 +28,7 @@ pub fn factory<T>(
factory: T, factory: T,
) -> BoxedNewService<T::Config, T::Request, T::Response, T::Error, T::InitError> ) -> BoxedNewService<T::Config, T::Request, T::Response, T::Error, T::InitError>
where where
T: Factory + 'static, T: ServiceFactory + 'static,
T::Request: 'static, T::Request: 'static,
T::Response: 'static, T::Response: 'static,
T::Service: 'static, T::Service: 'static,
@ -52,7 +52,7 @@ where
} }
type Inner<C, Req, Res, Err, InitErr> = Box< type Inner<C, Req, Res, Err, InitErr> = Box<
dyn Factory< dyn ServiceFactory<
Config = C, Config = C,
Request = Req, Request = Req,
Response = Res, Response = Res,
@ -63,7 +63,7 @@ type Inner<C, Req, Res, Err, InitErr> = Box<
>, >,
>; >;
impl<C, Req, Res, Err, InitErr> Factory for BoxedNewService<C, Req, Res, Err, InitErr> impl<C, Req, Res, Err, InitErr> ServiceFactory for BoxedNewService<C, Req, Res, Err, InitErr>
where where
Req: 'static, Req: 'static,
Res: 'static, Res: 'static,
@ -84,18 +84,24 @@ where
} }
} }
struct FactoryWrapper<C, T: Factory> { struct FactoryWrapper<C, T: ServiceFactory> {
factory: T, factory: T,
_t: std::marker::PhantomData<C>, _t: std::marker::PhantomData<C>,
} }
impl<C, T, Req, Res, Err, InitErr> Factory for FactoryWrapper<C, T> impl<C, T, Req, Res, Err, InitErr> ServiceFactory for FactoryWrapper<C, T>
where where
Req: 'static, Req: 'static,
Res: 'static, Res: 'static,
Err: 'static, Err: 'static,
InitErr: 'static, InitErr: 'static,
T: Factory<Config = C, Request = Req, Response = Res, Error = Err, InitError = InitErr>, T: ServiceFactory<
Config = C,
Request = Req,
Response = Res,
Error = Err,
InitError = InitErr,
>,
T::Future: 'static, T::Future: 'static,
T::Service: 'static, T::Service: 'static,
<T::Service as Service>::Future: 'static, <T::Service as Service>::Future: 'static,

View File

@ -6,12 +6,13 @@ use std::task::{Context, Poll};
use futures::future::{ok, Ready}; use futures::future::{ok, Ready};
use pin_project::pin_project; 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, Fut, Req, Res, Err, Cfg>( pub fn service_fn<F, Fut, Req, Res, Err, Cfg>(
f: F, f: F,
) -> impl Factory<Config = Cfg, Request = Req, Response = Res, Error = Err, InitError = ()> + Clone ) -> impl ServiceFactory<Config = Cfg, Request = Req, Response = Res, Error = Err, InitError = ()>
+ Clone
where where
F: FnMut(Req) -> Fut + Clone, F: FnMut(Req) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>, Fut: Future<Output = Result<Res, Err>>,
@ -19,10 +20,10 @@ where
NewServiceFn::new(f) NewServiceFn::new(f)
} }
/// Create `Factory` for function that can produce services /// Create `ServiceFactory` for function that can produce services
pub fn service_fn_factory<S, F, Cfg, Fut, Err>( pub fn service_fn_factory<S, F, Cfg, Fut, Err>(
f: F, f: F,
) -> impl Factory< ) -> impl ServiceFactory<
Config = Cfg, Config = Cfg,
Request = S::Request, Request = S::Request,
Response = S::Response, Response = S::Response,
@ -38,10 +39,10 @@ where
FnNewServiceNoConfig::new(f) 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, Fut, Cfg, Srv, Err>( pub fn service_fn_config<F, Fut, Cfg, Srv, Err>(
f: F, f: F,
) -> impl Factory< ) -> impl ServiceFactory<
Config = Cfg, Config = Cfg,
Request = Srv::Request, Request = Srv::Request,
Response = Srv::Response, Response = Srv::Response,
@ -143,7 +144,7 @@ where
} }
} }
impl<F, Fut, Req, Res, Err, Cfg> Factory for NewServiceFn<F, Fut, Req, Res, Err, Cfg> impl<F, Fut, Req, Res, Err, Cfg> ServiceFactory for NewServiceFn<F, Fut, Req, Res, Err, Cfg>
where where
F: FnMut(Req) -> Fut + Clone, F: FnMut(Req) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>, Fut: Future<Output = Result<Res, Err>>,
@ -184,7 +185,7 @@ where
} }
} }
impl<F, Fut, Cfg, Srv, Err> Factory for FnNewServiceConfig<F, Fut, Cfg, Srv, Err> impl<F, Fut, Cfg, Srv, Err> ServiceFactory for FnNewServiceConfig<F, Fut, Cfg, Srv, Err>
where where
F: Fn(&Cfg) -> Fut, F: Fn(&Cfg) -> Fut,
Fut: Future<Output = Result<Srv, Err>>, Fut: Future<Output = Result<Srv, Err>>,
@ -252,7 +253,7 @@ where
} }
} }
impl<F, C, R, S, E> Factory for FnNewServiceNoConfig<F, C, R, S, E> impl<F, C, R, S, E> ServiceFactory for FnNewServiceNoConfig<F, C, R, S, E>
where where
F: Fn() -> R, F: Fn() -> R,
R: Future<Output = Result<S, E>>, R: Future<Output = Result<S, E>>,
@ -282,7 +283,7 @@ where
} }
} }
impl<F, C, R, S, E> IntoFactory<FnNewServiceNoConfig<F, C, R, S, E>> for F impl<F, C, R, S, E> IntoServiceFactory<FnNewServiceNoConfig<F, C, R, S, E>> for F
where where
F: Fn() -> R, F: Fn() -> R,
R: Future<Output = Result<S, E>>, R: Future<Output = Result<S, E>>,

View File

@ -3,7 +3,7 @@ use std::task::{Context, Poll};
use crate::map::{Map, MapNewService}; use crate::map::{Map, MapNewService};
use crate::map_err::{MapErr, MapErrNewService}; use crate::map_err::{MapErr, MapErrNewService};
use crate::map_init_err::MapInitErr; use crate::map_init_err::MapInitErr;
use crate::{Factory, IntoFactory, IntoService, Service}; use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory};
#[inline] #[inline]
/// Convert object of type `U` to a service `T` /// Convert object of type `U` to a service `T`
@ -17,12 +17,12 @@ where
} }
} }
pub fn into_factory<T, F>(factory: F) -> FactoryMapper<T> pub fn into_factory<T, F>(factory: F) -> ServiceFactoryMapper<T>
where where
T: Factory, T: ServiceFactory,
F: IntoFactory<T>, F: IntoServiceFactory<T>,
{ {
FactoryMapper { ServiceFactoryMapper {
factory: factory.into_factory(), factory: factory.into_factory(),
} }
} }
@ -31,7 +31,7 @@ pub struct ServiceMapper<T> {
service: T, service: T,
} }
pub struct FactoryMapper<T> { pub struct ServiceFactoryMapper<T> {
factory: T, factory: T,
} }
@ -108,14 +108,14 @@ impl<T: Service> Service for ServiceMapper<T> {
} }
} }
impl<T: Factory> FactoryMapper<T> { impl<T: ServiceFactory> ServiceFactoryMapper<T> {
/// Map this service's output to a different type, returning a new service /// Map this service's output to a different type, returning a new service
/// of the resulting type. /// of the resulting type.
pub fn map<F, R>( pub fn map<F, R>(
self, self,
f: F, f: F,
) -> FactoryMapper< ) -> ServiceFactoryMapper<
impl Factory< impl ServiceFactory<
Config = T::Config, Config = T::Config,
Request = T::Request, Request = T::Request,
Response = R, Response = R,
@ -127,7 +127,7 @@ impl<T: Factory> FactoryMapper<T> {
Self: Sized, Self: Sized,
F: FnMut(T::Response) -> R + Clone, F: FnMut(T::Response) -> R + Clone,
{ {
FactoryMapper { ServiceFactoryMapper {
factory: MapNewService::new(self.factory, f), factory: MapNewService::new(self.factory, f),
} }
} }
@ -136,8 +136,8 @@ impl<T: Factory> FactoryMapper<T> {
pub fn map_err<F, E>( pub fn map_err<F, E>(
self, self,
f: F, f: F,
) -> FactoryMapper< ) -> ServiceFactoryMapper<
impl Factory< impl ServiceFactory<
Config = T::Config, Config = T::Config,
Request = T::Request, Request = T::Request,
Response = T::Response, Response = T::Response,
@ -149,7 +149,7 @@ impl<T: Factory> FactoryMapper<T> {
Self: Sized, Self: Sized,
F: Fn(T::Error) -> E + Clone, F: Fn(T::Error) -> E + Clone,
{ {
FactoryMapper { ServiceFactoryMapper {
factory: MapErrNewService::new(self.factory, f), factory: MapErrNewService::new(self.factory, f),
} }
} }
@ -158,8 +158,8 @@ impl<T: Factory> FactoryMapper<T> {
pub fn map_init_err<F, E>( pub fn map_init_err<F, E>(
self, self,
f: F, f: F,
) -> FactoryMapper< ) -> ServiceFactoryMapper<
impl Factory< impl ServiceFactory<
Config = T::Config, Config = T::Config,
Request = T::Request, Request = T::Request,
Response = T::Response, Response = T::Response,
@ -171,24 +171,24 @@ impl<T: Factory> FactoryMapper<T> {
Self: Sized, Self: Sized,
F: Fn(T::InitError) -> E + Clone, F: Fn(T::InitError) -> E + Clone,
{ {
FactoryMapper { ServiceFactoryMapper {
factory: MapInitErr::new(self.factory, f), factory: MapInitErr::new(self.factory, f),
} }
} }
} }
impl<T> Clone for FactoryMapper<T> impl<T> Clone for ServiceFactoryMapper<T>
where where
T: Clone, T: Clone,
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
FactoryMapper { ServiceFactoryMapper {
factory: self.factory.clone(), factory: self.factory.clone(),
} }
} }
} }
impl<T: Factory> Factory for FactoryMapper<T> { impl<T: ServiceFactory> ServiceFactory for ServiceFactoryMapper<T> {
type Config = T::Config; type Config = T::Config;
type Request = T::Request; type Request = T::Request;
type Response = T::Response; type Response = T::Response;

View File

@ -23,7 +23,7 @@ mod transform_err;
pub use self::apply::{apply_fn, apply_fn_factory}; pub use self::apply::{apply_fn, apply_fn_factory};
pub use self::apply_cfg::{apply_cfg, apply_cfg_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::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::map_config::{map_config, unit_config, MappedConfig};
pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory}; pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory};
pub use self::transform::{apply_transform, IntoTransform, Transform}; pub use self::transform::{apply_transform, IntoTransform, Transform};
@ -74,7 +74,7 @@ pub trait Service {
/// requests on that new TCP stream. /// requests on that new TCP stream.
/// ///
/// `Config` is a service factory configuration type. /// `Config` is a service factory configuration type.
pub trait Factory { pub trait ServiceFactory {
/// Requests handled by the service. /// Requests handled by the service.
type Request; type Request;
@ -158,9 +158,9 @@ where
} }
} }
impl<S> Factory for Rc<S> impl<S> ServiceFactory for Rc<S>
where where
S: Factory, S: ServiceFactory,
{ {
type Request = S::Request; type Request = S::Request;
type Response = S::Response; type Response = S::Response;
@ -175,9 +175,9 @@ where
} }
} }
impl<S> Factory for Arc<S> impl<S> ServiceFactory for Arc<S>
where where
S: Factory, S: ServiceFactory,
{ {
type Request = S::Request; type Request = S::Request;
type Response = S::Response; type Response = S::Response;
@ -201,10 +201,10 @@ where
fn into_service(self) -> T; fn into_service(self) -> T;
} }
/// Trait for types that can be converted to a `Factory` /// Trait for types that can be converted to a `ServiceFactory`
pub trait IntoFactory<T> pub trait IntoServiceFactory<T>
where where
T: Factory, T: ServiceFactory,
{ {
/// Convert `Self` an `ServiceFactory` /// Convert `Self` an `ServiceFactory`
fn into_factory(self) -> T; fn into_factory(self) -> T;
@ -219,9 +219,9 @@ where
} }
} }
impl<T> IntoFactory<T> for T impl<T> IntoServiceFactory<T> for T
where where
T: Factory, T: ServiceFactory,
{ {
fn into_factory(self) -> T { fn into_factory(self) -> T {
self self

View File

@ -5,7 +5,7 @@ use std::task::{Context, Poll};
use pin_project::pin_project; 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. /// Service for the `map` combinator, changing the type of a service's response.
/// ///
@ -113,7 +113,7 @@ impl<A, F, Res> MapNewService<A, F, Res> {
/// Create new `Map` new service instance /// Create new `Map` new service instance
pub fn new(a: A, f: F) -> Self pub fn new(a: A, f: F) -> Self
where where
A: Factory, A: ServiceFactory,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
Self { Self {
@ -138,9 +138,9 @@ where
} }
} }
impl<A, F, Res> Factory for MapNewService<A, F, Res> impl<A, F, Res> ServiceFactory for MapNewService<A, F, Res>
where where
A: Factory, A: ServiceFactory,
F: FnMut(A::Response) -> Res + Clone, F: FnMut(A::Response) -> Res + Clone,
{ {
type Request = A::Request; type Request = A::Request;
@ -160,7 +160,7 @@ where
#[pin_project] #[pin_project]
pub(crate) struct MapNewServiceFuture<A, F, Res> pub(crate) struct MapNewServiceFuture<A, F, Res>
where where
A: Factory, A: ServiceFactory,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
#[pin] #[pin]
@ -170,7 +170,7 @@ where
impl<A, F, Res> MapNewServiceFuture<A, F, Res> impl<A, F, Res> MapNewServiceFuture<A, F, Res>
where where
A: Factory, A: ServiceFactory,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
fn new(fut: A::Future, f: F) -> Self { fn new(fut: A::Future, f: F) -> Self {
@ -180,7 +180,7 @@ where
impl<A, F, Res> Future for MapNewServiceFuture<A, F, Res> impl<A, F, Res> Future for MapNewServiceFuture<A, F, Res>
where where
A: Factory, A: ServiceFactory,
F: FnMut(A::Response) -> Res, F: FnMut(A::Response) -> Res,
{ {
type Output = Result<Map<A::Service, F, Res>, A::InitError>; type Output = Result<Map<A::Service, F, Res>, A::InitError>;
@ -200,7 +200,7 @@ mod tests {
use futures::future::{ok, Ready}; use futures::future::{ok, Ready};
use super::*; use super::*;
use crate::{IntoFactory, Service}; use crate::{IntoServiceFactory, Service};
struct Srv; struct Srv;

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use super::Factory; use super::ServiceFactory;
pub enum MappedConfig<'a, T> { pub enum MappedConfig<'a, T> {
Ref(&'a T), Ref(&'a T),
@ -11,7 +11,7 @@ pub enum MappedConfig<'a, T> {
pub fn map_config<T, F, C>( pub fn map_config<T, F, C>(
factory: T, factory: T,
f: F, f: F,
) -> impl Factory< ) -> impl ServiceFactory<
Config = C, Config = C,
Request = T::Request, Request = T::Request,
Response = T::Response, Response = T::Response,
@ -19,7 +19,7 @@ pub fn map_config<T, F, C>(
InitError = T::InitError, InitError = T::InitError,
> >
where where
T: Factory, T: ServiceFactory,
F: Fn(&C) -> MappedConfig<T::Config>, F: Fn(&C) -> MappedConfig<T::Config>,
{ {
MapConfig::new(factory, f) MapConfig::new(factory, f)
@ -28,7 +28,7 @@ where
/// Replace config with unit /// Replace config with unit
pub fn unit_config<T, C>( pub fn unit_config<T, C>(
new_service: T, new_service: T,
) -> impl Factory< ) -> impl ServiceFactory<
Config = C, Config = C,
Request = T::Request, Request = T::Request,
Response = T::Response, Response = T::Response,
@ -36,7 +36,7 @@ pub fn unit_config<T, C>(
InitError = T::InitError, InitError = T::InitError,
> >
where where
T: Factory<Config = ()>, T: ServiceFactory<Config = ()>,
{ {
UnitConfig::new(new_service) UnitConfig::new(new_service)
} }
@ -52,7 +52,7 @@ impl<A, F, C> MapConfig<A, F, C> {
/// Create new `MapConfig` combinator /// Create new `MapConfig` combinator
pub fn new(a: A, f: F) -> Self pub fn new(a: A, f: F) -> Self
where where
A: Factory, A: ServiceFactory,
F: Fn(&C) -> MappedConfig<A::Config>, F: Fn(&C) -> MappedConfig<A::Config>,
{ {
Self { Self {
@ -77,9 +77,9 @@ where
} }
} }
impl<A, F, C> Factory for MapConfig<A, F, C> impl<A, F, C> ServiceFactory for MapConfig<A, F, C>
where where
A: Factory, A: ServiceFactory,
F: Fn(&C) -> MappedConfig<A::Config>, F: Fn(&C) -> MappedConfig<A::Config>,
{ {
type Request = A::Request; type Request = A::Request;
@ -107,7 +107,7 @@ pub(crate) struct UnitConfig<A, C> {
impl<A, C> UnitConfig<A, C> impl<A, C> UnitConfig<A, C>
where where
A: Factory<Config = ()>, A: ServiceFactory<Config = ()>,
{ {
/// Create new `UnitConfig` combinator /// Create new `UnitConfig` combinator
pub(crate) fn new(a: A) -> Self { pub(crate) fn new(a: A) -> Self {
@ -127,9 +127,9 @@ where
} }
} }
impl<A, C> Factory for UnitConfig<A, C> impl<A, C> ServiceFactory for UnitConfig<A, C>
where where
A: Factory<Config = ()>, A: ServiceFactory<Config = ()>,
{ {
type Request = A::Request; type Request = A::Request;
type Response = A::Response; type Response = A::Response;

View File

@ -5,7 +5,7 @@ use std::task::{Context, Poll};
use pin_project::pin_project; 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 /// Service for the `map_err` combinator, changing the type of a service's
/// error. /// error.
@ -105,7 +105,7 @@ where
/// This is created by the `NewServiceExt::map_err` method. /// This is created by the `NewServiceExt::map_err` method.
pub(crate) struct MapErrNewService<A, F, E> pub(crate) struct MapErrNewService<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::Error) -> E + Clone, F: Fn(A::Error) -> E + Clone,
{ {
a: A, a: A,
@ -115,7 +115,7 @@ where
impl<A, F, E> MapErrNewService<A, F, E> impl<A, F, E> MapErrNewService<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::Error) -> E + Clone, F: Fn(A::Error) -> E + Clone,
{ {
/// Create new `MapErr` new service instance /// Create new `MapErr` new service instance
@ -130,7 +130,7 @@ where
impl<A, F, E> Clone for MapErrNewService<A, F, E> impl<A, F, E> Clone for MapErrNewService<A, F, E>
where where
A: Factory + Clone, A: ServiceFactory + Clone,
F: Fn(A::Error) -> E + Clone, F: Fn(A::Error) -> E + Clone,
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
@ -142,9 +142,9 @@ where
} }
} }
impl<A, F, E> Factory for MapErrNewService<A, F, E> impl<A, F, E> ServiceFactory for MapErrNewService<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::Error) -> E + Clone, F: Fn(A::Error) -> E + Clone,
{ {
type Request = A::Request; type Request = A::Request;
@ -164,7 +164,7 @@ where
#[pin_project] #[pin_project]
pub(crate) struct MapErrNewServiceFuture<A, F, E> pub(crate) struct MapErrNewServiceFuture<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::Error) -> E, F: Fn(A::Error) -> E,
{ {
#[pin] #[pin]
@ -174,7 +174,7 @@ where
impl<A, F, E> MapErrNewServiceFuture<A, F, E> impl<A, F, E> MapErrNewServiceFuture<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::Error) -> E, F: Fn(A::Error) -> E,
{ {
fn new(fut: A::Future, f: F) -> Self { fn new(fut: A::Future, f: F) -> Self {
@ -184,7 +184,7 @@ where
impl<A, F, E> Future for MapErrNewServiceFuture<A, F, E> impl<A, F, E> Future for MapErrNewServiceFuture<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::Error) -> E + Clone, F: Fn(A::Error) -> E + Clone,
{ {
type Output = Result<MapErr<A::Service, F, E>, A::InitError>; type Output = Result<MapErr<A::Service, F, E>, A::InitError>;

View File

@ -5,7 +5,7 @@ use std::task::{Context, Poll};
use pin_project::pin_project; use pin_project::pin_project;
use super::Factory; use super::ServiceFactory;
/// `MapInitErr` service combinator /// `MapInitErr` service combinator
pub(crate) struct MapInitErr<A, F, E> { pub(crate) struct MapInitErr<A, F, E> {
@ -16,7 +16,7 @@ pub(crate) struct MapInitErr<A, F, E> {
impl<A, F, E> MapInitErr<A, F, E> impl<A, F, E> MapInitErr<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
/// Create new `MapInitErr` combinator /// Create new `MapInitErr` combinator
@ -43,9 +43,9 @@ where
} }
} }
impl<A, F, E> Factory for MapInitErr<A, F, E> impl<A, F, E> ServiceFactory for MapInitErr<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::InitError) -> E + Clone, F: Fn(A::InitError) -> E + Clone,
{ {
type Request = A::Request; type Request = A::Request;
@ -64,7 +64,7 @@ where
#[pin_project] #[pin_project]
pub(crate) struct MapInitErrFuture<A, F, E> pub(crate) struct MapInitErrFuture<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
f: F, f: F,
@ -74,7 +74,7 @@ where
impl<A, F, E> MapInitErrFuture<A, F, E> impl<A, F, E> MapInitErrFuture<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
fn new(fut: A::Future, f: F) -> Self { fn new(fut: A::Future, f: F) -> Self {
@ -84,7 +84,7 @@ where
impl<A, F, E> Future for MapInitErrFuture<A, F, E> impl<A, F, E> Future for MapInitErrFuture<A, F, E>
where where
A: Factory, A: ServiceFactory,
F: Fn(A::InitError) -> E, F: Fn(A::InitError) -> E,
{ {
type Output = Result<A::Service, E>; type Output = Result<A::Service, E>;

View File

@ -2,7 +2,7 @@ use std::task::{Context, Poll};
use crate::and_then::{AndThen, AndThenNewService}; use crate::and_then::{AndThen, AndThenNewService};
use crate::then::{Then, ThenNewService}; use crate::then::{Then, ThenNewService};
use crate::{Factory, IntoFactory, IntoService, Service}; use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory};
pub fn pipeline<F, T>(service: F) -> Pipeline<T> pub fn pipeline<F, T>(service: F) -> Pipeline<T>
where where
@ -16,8 +16,8 @@ where
pub fn pipeline_factory<T, F>(factory: F) -> PipelineFactory<T> pub fn pipeline_factory<T, F>(factory: F) -> PipelineFactory<T>
where where
T: Factory, T: ServiceFactory,
F: IntoFactory<T>, F: IntoServiceFactory<T>,
{ {
PipelineFactory { PipelineFactory {
factory: factory.into_factory(), factory: factory.into_factory(),
@ -106,13 +106,13 @@ pub struct PipelineFactory<T> {
factory: T, factory: T,
} }
impl<T: Factory> PipelineFactory<T> { impl<T: ServiceFactory> PipelineFactory<T> {
/// Call another service after call to this one has resolved successfully. /// Call another service after call to this one has resolved successfully.
pub fn and_then<F, U>( pub fn and_then<F, U>(
self, self,
factory: U, factory: U,
) -> PipelineFactory< ) -> PipelineFactory<
impl Factory< impl ServiceFactory<
Config = T::Config, Config = T::Config,
Request = T::Request, Request = T::Request,
Response = U::Response, Response = U::Response,
@ -122,8 +122,8 @@ impl<T: Factory> PipelineFactory<T> {
> >
where where
Self: Sized, Self: Sized,
F: IntoFactory<U>, F: IntoServiceFactory<U>,
U: Factory< U: ServiceFactory<
Config = T::Config, Config = T::Config,
Request = T::Response, Request = T::Response,
Error = T::Error, Error = T::Error,
@ -145,7 +145,7 @@ impl<T: Factory> PipelineFactory<T> {
self, self,
factory: F, factory: F,
) -> PipelineFactory< ) -> PipelineFactory<
impl Factory< impl ServiceFactory<
Config = T::Config, Config = T::Config,
Request = T::Request, Request = T::Request,
Response = U::Response, Response = U::Response,
@ -155,8 +155,8 @@ impl<T: Factory> PipelineFactory<T> {
> >
where where
Self: Sized, Self: Sized,
F: IntoFactory<U>, F: IntoServiceFactory<U>,
U: Factory< U: ServiceFactory<
Config = T::Config, Config = T::Config,
Request = Result<T::Response, T::Error>, Request = Result<T::Response, T::Error>,
Error = T::Error, Error = T::Error,
@ -180,7 +180,7 @@ where
} }
} }
impl<T: Factory> Factory for PipelineFactory<T> { impl<T: ServiceFactory> ServiceFactory for PipelineFactory<T> {
type Config = T::Config; type Config = T::Config;
type Request = T::Request; type Request = T::Request;
type Response = T::Response; type Response = T::Response;

View File

@ -4,7 +4,7 @@ use std::task::{Context, Poll};
use pin_project::pin_project; use pin_project::pin_project;
use super::{Factory, Service}; use super::{Service, ServiceFactory};
use crate::cell::Cell; use crate::cell::Cell;
/// Service for the `then` combinator, chaining a computation onto the end of /// Service for the `then` combinator, chaining a computation onto the end of
@ -134,8 +134,8 @@ pub(crate) struct ThenNewService<A, B> {
impl<A, B> ThenNewService<A, B> impl<A, B> ThenNewService<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = Result<A::Response, A::Error>, Request = Result<A::Response, A::Error>,
Error = A::Error, Error = A::Error,
@ -148,10 +148,10 @@ where
} }
} }
impl<A, B> Factory for ThenNewService<A, B> impl<A, B> ServiceFactory for ThenNewService<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = Result<A::Response, A::Error>, Request = Result<A::Response, A::Error>,
Error = A::Error, Error = A::Error,
@ -188,8 +188,8 @@ where
#[pin_project] #[pin_project]
pub(crate) struct ThenNewServiceFuture<A, B> pub(crate) struct ThenNewServiceFuture<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = Result<A::Response, A::Error>, Request = Result<A::Response, A::Error>,
Error = A::Error, Error = A::Error,
@ -206,8 +206,8 @@ where
impl<A, B> ThenNewServiceFuture<A, B> impl<A, B> ThenNewServiceFuture<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = Result<A::Response, A::Error>, Request = Result<A::Response, A::Error>,
Error = A::Error, Error = A::Error,
@ -226,8 +226,8 @@ where
impl<A, B> Future for ThenNewServiceFuture<A, B> impl<A, B> Future for ThenNewServiceFuture<A, B>
where where
A: Factory, A: ServiceFactory,
B: Factory< B: ServiceFactory<
Config = A::Config, Config = A::Config,
Request = Result<A::Response, A::Error>, Request = Result<A::Response, A::Error>,
Error = A::Error, Error = A::Error,
@ -267,7 +267,7 @@ mod tests {
use futures::future::{err, ok, ready, Ready}; use futures::future::{err, ok, ready, Ready};
use crate::{pipeline, pipeline_factory, Factory, Service}; use crate::{pipeline, pipeline_factory, Service, ServiceFactory};
#[derive(Clone)] #[derive(Clone)]
struct Srv1(Rc<Cell<usize>>); struct Srv1(Rc<Cell<usize>>);

View File

@ -5,7 +5,7 @@ use std::sync::Arc;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use crate::transform_err::{TransformFromErr, TransformMapInitErr}; use crate::transform_err::{TransformFromErr, TransformMapInitErr};
use crate::{Factory, IntoFactory, Service}; use crate::{IntoServiceFactory, Service, ServiceFactory};
use pin_project::pin_project; use pin_project::pin_project;
@ -133,7 +133,7 @@ where
pub fn apply_transform<T, S, F, U>( pub fn apply_transform<T, S, F, U>(
t: F, t: F,
service: U, service: U,
) -> impl Factory< ) -> impl ServiceFactory<
Config = S::Config, Config = S::Config,
Request = T::Request, Request = T::Request,
Response = T::Response, Response = T::Response,
@ -142,10 +142,10 @@ pub fn apply_transform<T, S, F, U>(
InitError = S::InitError, InitError = S::InitError,
> + Clone > + Clone
where where
S: Factory, S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>, T: Transform<S::Service, InitError = S::InitError>,
F: IntoTransform<T, S::Service>, F: IntoTransform<T, S::Service>,
U: IntoFactory<S>, U: IntoServiceFactory<S>,
{ {
ApplyTransform::new(t.into_transform(), service.into_factory()) ApplyTransform::new(t.into_transform(), service.into_factory())
} }
@ -158,7 +158,7 @@ pub struct ApplyTransform<T, S> {
impl<T, S> ApplyTransform<T, S> impl<T, S> ApplyTransform<T, S>
where where
S: Factory, S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>, T: Transform<S::Service, InitError = S::InitError>,
{ {
/// Create new `ApplyTransform` new service instance /// Create new `ApplyTransform` new service instance
@ -179,9 +179,9 @@ impl<T, S> Clone for ApplyTransform<T, S> {
} }
} }
impl<T, S> Factory for ApplyTransform<T, S> impl<T, S> ServiceFactory for ApplyTransform<T, S>
where where
S: Factory, S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>, T: Transform<S::Service, InitError = S::InitError>,
{ {
type Request = T::Request; type Request = T::Request;
@ -204,7 +204,7 @@ where
#[pin_project] #[pin_project]
pub struct ApplyTransformFuture<T, S> pub struct ApplyTransformFuture<T, S>
where where
S: Factory, S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>, T: Transform<S::Service, InitError = S::InitError>,
{ {
#[pin] #[pin]
@ -216,7 +216,7 @@ where
impl<T, S> Future for ApplyTransformFuture<T, S> impl<T, S> Future for ApplyTransformFuture<T, S>
where where
S: Factory, S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>, T: Transform<S::Service, InitError = S::InitError>,
{ {
type Output = Result<T::Transform, T::InitError>; type Output = Result<T::Transform, T::InitError>;