[][src]Trait ntex::service::ServiceFactory

pub trait ServiceFactory where
    <Self::Service as Service>::Request == Self::Request,
    <Self::Service as Service>::Response == Self::Response,
    <Self::Service as Service>::Error == Self::Error,
    <Self::Future as Future>::Output == Result<Self::Service, Self::InitError>, 
{ type Request; type Response; type Error; type Config; type Service: Service; type InitError; type Future: Future; fn new_service(&self, cfg: Self::Config) -> Self::Future; fn map<F, R>(self, f: F) -> MapServiceFactory<Self, F, R>
    where
        F: FnMut(Self::Response) -> R + Clone
, { ... }
fn map_err<F, E>(self, f: F) -> MapErrServiceFactory<Self, F, E>
    where
        F: Fn(Self::Error) -> E + Clone
, { ... }
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E>
    where
        F: Fn(Self::InitError) -> E + Clone
, { ... } }

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.

Loading content...

Required methods

fn new_service(&self, cfg: Self::Config) -> Self::Future

Create and return a new service value asynchronously.

Loading content...

Provided methods

fn map<F, R>(self, f: F) -> MapServiceFactory<Self, F, R> where
    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

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

Map this factory's init error to a different error, returning a new service.

Loading content...

Implementations on Foreign Types

impl<S> ServiceFactory for Rc<S> where
    S: ServiceFactory
[src]

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

impl<S> ServiceFactory for Arc<S> where
    S: ServiceFactory
[src]

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

Loading content...

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>>

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>>

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]

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>

impl<A, C> ServiceFactory for UnitConfig<A, C> where
    A: ServiceFactory<Config = ()>, 
[src]

impl<A, F, C> ServiceFactory for MapConfig<A, F, C> where
    A: ServiceFactory,
    F: Fn(C) -> <A as ServiceFactory>::Config
[src]

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

impl<A, F, E> ServiceFactory for MapErrServiceFactory<A, F, E> where
    A: ServiceFactory,
    F: Fn(<A as ServiceFactory>::Error) -> E + Clone
[src]

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>

impl<A, F, E> ServiceFactory for MapInitErr<A, F, E> where
    A: ServiceFactory,
    F: Fn(<A as ServiceFactory>::InitError) -> E + Clone
[src]

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>

impl<A, F, Res> ServiceFactory for MapServiceFactory<A, F, Res> where
    A: ServiceFactory,
    F: FnMut(<A as ServiceFactory>::Response) -> Res + Clone
[src]

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>

impl<C, Req, Res, Err, InitErr> ServiceFactory for BoxServiceFactory<C, Req, Res, Err, InitErr> where
    Err: 'static,
    InitErr: 'static,
    Req: 'static,
    Res: 'static, 
[src]

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>>

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>, ()>>

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]

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

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]

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

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]

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>>

impl<R, E, F> ServiceFactory for KeepAlive<R, E, F> where
    F: Fn() -> E + Clone
[src]

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>>

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>>

impl<T> ServiceFactory for ntex::server::openssl::Acceptor<T> where
    T: AsyncRead + AsyncWrite + Unpin + Debug + 'static, 
[src]

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>>

impl<T> ServiceFactory for PipelineFactory<T> where
    T: ServiceFactory
[src]

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]

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>

impl<T, S> ServiceFactory for ApplyTransform<T, S> where
    S: ServiceFactory,
    T: Transform<<S as ServiceFactory>::Service, InitError = <S as ServiceFactory>::InitError>, 
[src]

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>

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]

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>

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]

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>

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]

type Config = ()

type Request = (T, Protocol, Option<SocketAddr>)

type Response = ()

type Error = DispatchError

type InitError = ()

type Service = HttpServiceHandler<T, S::Service, B, X::Service, U::Service>

type Future = HttpServiceResponse<T, S, B, X, U>

impl<T: AsyncRead + AsyncWrite + Unpin> ServiceFactory for ntex::server::rustls::Acceptor<T>[src]

type Request = T

type Response = TlsStream<T>

type Error = Box<dyn Error>

type Service = AcceptorService<T>

type Config = ()

type InitError = ()

type Future = Ready<Result<Self::Service, Self::InitError>>

impl<T: Address + 'static> ServiceFactory for OpensslConnector<T>[src]

type Request = Connect<T>

type Response = SslStream<TcpStream>

type Error = ConnectError

type Config = ()

type Service = OpensslConnector<T>

type InitError = ()

type Future = Ready<Result<Self::Service, Self::InitError>>

impl<T: Address + 'static> ServiceFactory for RustlsConnector<T>[src]

type Request = Connect<T>

type Response = TlsStream<TcpStream>

type Error = ConnectError

type Config = ()

type Service = RustlsConnector<T>

type InitError = ()

type Future = Ready<Result<Self::Service, Self::InitError>>

impl<T: Address> ServiceFactory for Connector<T>[src]

type Request = Connect<T>

type Response = TcpStream

type Error = ConnectError

type Config = ()

type Service = Connector<T>

type InitError = ()

type Future = Ready<Result<Self::Service, Self::InitError>>

impl<T: Address> ServiceFactory for Resolver<T>[src]

type Request = Connect<T>

type Response = Connect<T>

type Error = ConnectError

type Config = ()

type Service = Resolver<T>

type InitError = ()

type Future = Ready<Result<Self::Service, Self::InitError>>

Loading content...