[−][src]Trait ntex::service::ServiceFactory
Creates new Service
values.
Acts as a service factory. This is useful for cases where new Service
values must be produced. One case is a TCP server listener. The listener
accepts new TCP streams, obtains a new Service
value using the
ServiceFactory
trait, and uses that new Service
value to process inbound
requests on that new TCP stream.
Config
is a service factory configuration type.
Associated Types
type Request
Requests handled by the service.
type Response
Responses given by the service
type Error
Errors produced by the service
type Config
Service factory configuration
type Service: Service
The Service
value created by this factory
type InitError
Errors produced while building a service.
type Future: Future
The future of the Service
instance.
Required methods
fn new_service(&self, cfg: Self::Config) -> Self::Future
Create and return a new service value asynchronously.
Provided methods
fn map<F, R>(self, f: F) -> MapServiceFactory<Self, F, R> where
F: FnMut(Self::Response) -> R + Clone,
F: FnMut(Self::Response) -> R + Clone,
Map this service's output to a different type, returning a new service of the resulting type.
fn map_err<F, E>(self, f: F) -> MapErrServiceFactory<Self, F, E> where
F: Fn(Self::Error) -> E + Clone,
F: Fn(Self::Error) -> E + Clone,
Map this service's error to a different error, returning a new service.
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
F: Fn(Self::InitError) -> E + Clone,
F: Fn(Self::InitError) -> E + Clone,
Map this factory's init error to a different error, returning a new service.
Implementations on Foreign Types
impl<S> ServiceFactory for Rc<S> where
S: ServiceFactory,
[src]
S: ServiceFactory,
type Request = <S as ServiceFactory>::Request
type Response = <S as ServiceFactory>::Response
type Error = <S as ServiceFactory>::Error
type Config = <S as ServiceFactory>::Config
type Service = <S as ServiceFactory>::Service
type InitError = <S as ServiceFactory>::InitError
type Future = <S as ServiceFactory>::Future
fn new_service(
&self,
cfg: <S as ServiceFactory>::Config
) -> <S as ServiceFactory>::Future
[src]
&self,
cfg: <S as ServiceFactory>::Config
) -> <S as ServiceFactory>::Future
impl<S> ServiceFactory for Arc<S> where
S: ServiceFactory,
[src]
S: ServiceFactory,
type Request = <S as ServiceFactory>::Request
type Response = <S as ServiceFactory>::Response
type Error = <S as ServiceFactory>::Error
type Config = <S as ServiceFactory>::Config
type Service = <S as ServiceFactory>::Service
type InitError = <S as ServiceFactory>::InitError
type Future = <S as ServiceFactory>::Future
fn new_service(
&self,
cfg: <S as ServiceFactory>::Config
) -> <S as ServiceFactory>::Future
[src]
&self,
cfg: <S as ServiceFactory>::Config
) -> <S as ServiceFactory>::Future
Implementors
impl ServiceFactory for ExpectHandler
[src]
type Config = ()
type Request = Request
type Response = Request
type Error = Error
type Service = ExpectHandler
type InitError = Error
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl ServiceFactory for LowResTime
[src]
type Request = ()
type Response = Instant
type Error = Infallible
type InitError = Infallible
type Config = ()
type Service = LowResTimeService
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<A, B> ServiceFactory for Either<A, B> where
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Response = A::Response, Error = A::Error, InitError = A::InitError>,
[src]
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Response = A::Response, Error = A::Error, InitError = A::InitError>,
type Request = Either<A::Request, B::Request>
type Response = A::Response
type Error = A::Error
type InitError = A::InitError
type Config = A::Config
type Service = EitherService<A::Service, B::Service>
type Future = EitherNewService<A, B>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<A, C> ServiceFactory for UnitConfig<A, C> where
A: ServiceFactory<Config = ()>,
[src]
A: ServiceFactory<Config = ()>,
type Request = <A as ServiceFactory>::Request
type Response = <A as ServiceFactory>::Response
type Error = <A as ServiceFactory>::Error
type Config = C
type Service = <A as ServiceFactory>::Service
type InitError = <A as ServiceFactory>::InitError
type Future = <A as ServiceFactory>::Future
fn new_service(&self, C) -> <UnitConfig<A, C> as ServiceFactory>::Future
[src]
impl<A, F, C> ServiceFactory for MapConfig<A, F, C> where
A: ServiceFactory,
F: Fn(C) -> <A as ServiceFactory>::Config,
[src]
A: ServiceFactory,
F: Fn(C) -> <A as ServiceFactory>::Config,
type Request = <A as ServiceFactory>::Request
type Response = <A as ServiceFactory>::Response
type Error = <A as ServiceFactory>::Error
type Config = C
type Service = <A as ServiceFactory>::Service
type InitError = <A as ServiceFactory>::InitError
type Future = <A as ServiceFactory>::Future
fn new_service(&self, cfg: C) -> <MapConfig<A, F, C> as ServiceFactory>::Future
[src]
impl<A, F, E> ServiceFactory for MapErrServiceFactory<A, F, E> where
A: ServiceFactory,
F: Fn(<A as ServiceFactory>::Error) -> E + Clone,
[src]
A: ServiceFactory,
F: Fn(<A as ServiceFactory>::Error) -> E + Clone,
type Request = <A as ServiceFactory>::Request
type Response = <A as ServiceFactory>::Response
type Error = E
type Config = <A as ServiceFactory>::Config
type Service = MapErr<<A as ServiceFactory>::Service, F, E>
type InitError = <A as ServiceFactory>::InitError
type Future = MapErrServiceFuture<A, F, E>
fn new_service(
&self,
cfg: <A as ServiceFactory>::Config
) -> <MapErrServiceFactory<A, F, E> as ServiceFactory>::Future
[src]
&self,
cfg: <A as ServiceFactory>::Config
) -> <MapErrServiceFactory<A, F, E> as ServiceFactory>::Future
impl<A, F, E> ServiceFactory for MapInitErr<A, F, E> where
A: ServiceFactory,
F: Fn(<A as ServiceFactory>::InitError) -> E + Clone,
[src]
A: ServiceFactory,
F: Fn(<A as ServiceFactory>::InitError) -> E + Clone,
type Request = <A as ServiceFactory>::Request
type Response = <A as ServiceFactory>::Response
type Error = <A as ServiceFactory>::Error
type Config = <A as ServiceFactory>::Config
type Service = <A as ServiceFactory>::Service
type InitError = E
type Future = MapInitErrFuture<A, F, E>
fn new_service(
&self,
cfg: <A as ServiceFactory>::Config
) -> <MapInitErr<A, F, E> as ServiceFactory>::Future
[src]
&self,
cfg: <A as ServiceFactory>::Config
) -> <MapInitErr<A, F, E> as ServiceFactory>::Future
impl<A, F, Res> ServiceFactory for MapServiceFactory<A, F, Res> where
A: ServiceFactory,
F: FnMut(<A as ServiceFactory>::Response) -> Res + Clone,
[src]
A: ServiceFactory,
F: FnMut(<A as ServiceFactory>::Response) -> Res + Clone,
type Request = <A as ServiceFactory>::Request
type Response = Res
type Error = <A as ServiceFactory>::Error
type Config = <A as ServiceFactory>::Config
type Service = Map<<A as ServiceFactory>::Service, F, Res>
type InitError = <A as ServiceFactory>::InitError
type Future = MapServiceFuture<A, F, Res>
fn new_service(
&self,
cfg: <A as ServiceFactory>::Config
) -> <MapServiceFactory<A, F, Res> as ServiceFactory>::Future
[src]
&self,
cfg: <A as ServiceFactory>::Config
) -> <MapServiceFactory<A, F, Res> as ServiceFactory>::Future
impl<C, Req, Res, Err, InitErr> ServiceFactory for BoxServiceFactory<C, Req, Res, Err, InitErr> where
Err: 'static,
InitErr: 'static,
Req: 'static,
Res: 'static,
[src]
Err: 'static,
InitErr: 'static,
Req: 'static,
Res: 'static,
type Request = Req
type Response = Res
type Error = Err
type InitError = InitErr
type Config = C
type Service = Box<dyn Service<Response = Res, Error = Err, Request = Req, Future = Pin<Box<dyn Future<Output = Result<Res, Err>> + 'static>>> + 'static>
type Future = Pin<Box<dyn Future<Output = Result<<BoxServiceFactory<C, Req, Res, Err, InitErr> as ServiceFactory>::Service, InitErr>> + 'static>>
fn new_service(
&self,
cfg: C
) -> <BoxServiceFactory<C, Req, Res, Err, InitErr> as ServiceFactory>::Future
[src]
&self,
cfg: C
) -> <BoxServiceFactory<C, Req, Res, Err, InitErr> as ServiceFactory>::Future
impl<Err: ErrorRenderer> ServiceFactory for Route<Err>
[src]
type Config = ()
type Request = WebRequest<Err>
type Response = WebResponse
type Error = Err::Container
type InitError = ()
type Service = RouteService<Err>
type Future = Ready<Result<RouteService<Err>, ()>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<F, C, S, R, E> ServiceFactory for FnServiceNoConfig<F, C, S, R, E> where
F: Fn() -> R,
R: Future<Output = Result<S, E>>,
S: Service,
[src]
F: Fn() -> R,
R: Future<Output = Result<S, E>>,
S: Service,
type Request = <S as Service>::Request
type Response = <S as Service>::Response
type Error = <S as Service>::Error
type Service = S
type Config = C
type InitError = E
type Future = R
fn new_service(
&self,
C
) -> <FnServiceNoConfig<F, C, S, R, E> as ServiceFactory>::Future
[src]
&self,
C
) -> <FnServiceNoConfig<F, C, S, R, E> as ServiceFactory>::Future
impl<F, Fut, Cfg, Srv, Err> ServiceFactory for FnServiceConfig<F, Fut, Cfg, Srv, Err> where
F: Fn(Cfg) -> Fut,
Fut: Future<Output = Result<Srv, Err>>,
Srv: Service,
[src]
F: Fn(Cfg) -> Fut,
Fut: Future<Output = Result<Srv, Err>>,
Srv: Service,
type Request = <Srv as Service>::Request
type Response = <Srv as Service>::Response
type Error = <Srv as Service>::Error
type Config = Cfg
type Service = Srv
type InitError = Err
type Future = Fut
fn new_service(
&self,
cfg: Cfg
) -> <FnServiceConfig<F, Fut, Cfg, Srv, Err> as ServiceFactory>::Future
[src]
&self,
cfg: Cfg
) -> <FnServiceConfig<F, Fut, Cfg, Srv, Err> as ServiceFactory>::Future
impl<F, Fut, Req, Res, Err, Cfg> ServiceFactory for FnServiceFactory<F, Fut, Req, Res, Err, Cfg> where
F: Fn(Req) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
[src]
F: Fn(Req) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
type Request = Req
type Response = Res
type Error = Err
type Config = Cfg
type Service = FnService<F, Fut, Req, Res, Err>
type InitError = ()
type Future = Ready<Result<<FnServiceFactory<F, Fut, Req, Res, Err, Cfg> as ServiceFactory>::Service, <FnServiceFactory<F, Fut, Req, Res, Err, Cfg> as ServiceFactory>::InitError>>
fn new_service(
&self,
Cfg
) -> <FnServiceFactory<F, Fut, Req, Res, Err, Cfg> as ServiceFactory>::Future
[src]
&self,
Cfg
) -> <FnServiceFactory<F, Fut, Req, Res, Err, Cfg> as ServiceFactory>::Future
impl<R, E, F> ServiceFactory for KeepAlive<R, E, F> where
F: Fn() -> E + Clone,
[src]
F: Fn() -> E + Clone,
type Request = R
type Response = R
type Error = E
type InitError = Infallible
type Config = ()
type Service = KeepAliveService<R, E, F>
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T> ServiceFactory for UpgradeHandler<T>
[src]
type Config = ()
type Request = (Request, Framed<T, Codec>)
type Response = ()
type Error = Error
type Service = UpgradeHandler<T>
type InitError = Error
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T> ServiceFactory for ntex::server::openssl::Acceptor<T> where
T: AsyncRead + AsyncWrite + Unpin + Debug + 'static,
[src]
T: AsyncRead + AsyncWrite + Unpin + Debug + 'static,
type Request = T
type Response = SslStream<T>
type Error = Box<dyn Error>
type Config = ()
type Service = AcceptorService<T>
type InitError = ()
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T> ServiceFactory for PipelineFactory<T> where
T: ServiceFactory,
[src]
T: ServiceFactory,
type Config = <T as ServiceFactory>::Config
type Request = <T as ServiceFactory>::Request
type Response = <T as ServiceFactory>::Response
type Error = <T as ServiceFactory>::Error
type Service = <T as ServiceFactory>::Service
type InitError = <T as ServiceFactory>::InitError
type Future = <T as ServiceFactory>::Future
fn new_service(
&self,
cfg: <T as ServiceFactory>::Config
) -> <PipelineFactory<T> as ServiceFactory>::Future
[src]
&self,
cfg: <T as ServiceFactory>::Config
) -> <PipelineFactory<T> as ServiceFactory>::Future
impl<T, F, R, In, Out, Err> ServiceFactory for ApplyServiceFactory<T, F, R, In, Out, Err> where
F: Fn(In, &<T as ServiceFactory>::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>,
T: ServiceFactory<Error = Err>,
[src]
F: Fn(In, &<T as ServiceFactory>::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>,
T: ServiceFactory<Error = Err>,
type Request = In
type Response = Out
type Error = Err
type Config = <T as ServiceFactory>::Config
type Service = Apply<<T as ServiceFactory>::Service, F, R, In, Out, Err>
type InitError = <T as ServiceFactory>::InitError
type Future = ApplyServiceFactoryResponse<T, F, R, In, Out, Err>
fn new_service(
&self,
cfg: <T as ServiceFactory>::Config
) -> <ApplyServiceFactory<T, F, R, In, Out, Err> as ServiceFactory>::Future
[src]
&self,
cfg: <T as ServiceFactory>::Config
) -> <ApplyServiceFactory<T, F, R, In, Out, Err> as ServiceFactory>::Future
impl<T, S> ServiceFactory for ApplyTransform<T, S> where
S: ServiceFactory,
T: Transform<<S as ServiceFactory>::Service, InitError = <S as ServiceFactory>::InitError>,
[src]
S: ServiceFactory,
T: Transform<<S as ServiceFactory>::Service, InitError = <S as ServiceFactory>::InitError>,
type Request = <T as Transform<<S as ServiceFactory>::Service>>::Request
type Response = <T as Transform<<S as ServiceFactory>::Service>>::Response
type Error = <T as Transform<<S as ServiceFactory>::Service>>::Error
type Config = <S as ServiceFactory>::Config
type Service = <T as Transform<<S as ServiceFactory>::Service>>::Transform
type InitError = <T as Transform<<S as ServiceFactory>::Service>>::InitError
type Future = ApplyTransformFuture<T, S>
fn new_service(
&self,
cfg: <S as ServiceFactory>::Config
) -> <ApplyTransform<T, S> as ServiceFactory>::Future
[src]
&self,
cfg: <S as ServiceFactory>::Config
) -> <ApplyTransform<T, S> as ServiceFactory>::Future
impl<T, S, B> ServiceFactory for H2Service<T, S, B> where
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
B: MessageBody + 'static,
[src]
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
B: MessageBody + 'static,
type Config = ()
type Request = (T, Option<SocketAddr>)
type Response = ()
type Error = DispatchError
type InitError = S::InitError
type Service = H2ServiceHandler<T, S::Service, B>
type Future = H2ServiceResponse<T, S, B>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T, S, B, X, U> ServiceFactory for H1Service<T, S, B, X, U> where
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError,
S::Response: Into<Response<B>>,
S::InitError: Debug,
B: MessageBody,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: ResponseError,
X::InitError: Debug,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + ResponseError,
U::InitError: Debug,
[src]
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError,
S::Response: Into<Response<B>>,
S::InitError: Debug,
B: MessageBody,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: ResponseError,
X::InitError: Debug,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + ResponseError,
U::InitError: Debug,
type Config = ()
type Request = (T, Option<SocketAddr>)
type Response = ()
type Error = DispatchError
type InitError = ()
type Service = H1ServiceHandler<T, S::Service, B, X::Service, U::Service>
type Future = H1ServiceResponse<T, S, B, X, U>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T, S, B, X, U> ServiceFactory for HttpService<T, S, B, X, U> where
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: ResponseError,
X::InitError: Debug,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + ResponseError,
U::InitError: Debug,
<U::Service as Service>::Future: 'static,
[src]
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: ResponseError,
X::InitError: Debug,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + ResponseError,
U::InitError: Debug,
<U::Service as Service>::Future: 'static,