[][src]Trait actix_service::ServiceFactory

pub trait ServiceFactory<Req> {
    type Response;
    type Error;
    type Config;
    type Service: Service<Req, Response = Self::Response, Error = Self::Error>;
    type InitError;
    type Future: Future<Output = Result<Self::Service, Self::InitError>>;
    pub fn new_service(&self, cfg: Self::Config) -> Self::Future;
}

Factory for creating Services.

Acts as a service factory. This is useful for cases where new Services must be produced. One case is a TCP server listener. The listener accepts new TCP streams, obtains a new Service using the ServiceFactory trait, and uses the new Service to process inbound requests on that new TCP stream.

Config is a service factory configuration type.

Associated Types

type Response[src]

Responses given by the created services.

type Error[src]

Errors produced by the created services.

type Config[src]

Service factory configuration.

type Service: Service<Req, Response = Self::Response, Error = Self::Error>[src]

The kind of Service created by this factory.

type InitError[src]

Errors potentially raised while building a service.

type Future: Future<Output = Result<Self::Service, Self::InitError>>[src]

The future of the Service instance.

Loading content...

Required methods

pub fn new_service(&self, cfg: Self::Config) -> Self::Future[src]

Create and return a new service asynchronously.

Loading content...

Implementations on Foreign Types

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

type Response = S::Response

type Error = S::Error

type Config = S::Config

type Service = S::Service

type InitError = S::InitError

type Future = S::Future

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

type Response = S::Response

type Error = S::Error

type Config = S::Config

type Service = S::Service

type InitError = S::InitError

type Future = S::Future

Loading content...

Implementors

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

type Response = A::Response

type Error = A::Error

type Config = A::Config

type Service = A::Service

type InitError = E

type Future = MapInitErrFuture<A, F, Req, E>

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

type Response = Res

type Error = A::Error

type Config = A::Config

type Service = Map<A::Service, F, Req, Res>

type InitError = A::InitError

type Future = MapServiceFuture<A, F, Req, Res>

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

type Response = A::Response

type Error = E

type Config = A::Config

type Service = MapErr<A::Service, Req, F, E>

type InitError = A::InitError

type Future = MapErrServiceFuture<A, Req, F, E>

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

type Response = Res

type Error = Err

type InitError = InitErr

type Config = C

type Service = BoxService<Req, Res, Err>

type Future = BoxFuture<Result<Self::Service, InitErr>>

impl<F, Cfg, Srv, Req, Fut, Err> ServiceFactory<Req> for FnServiceNoConfig<F, Cfg, Srv, Req, Fut, Err> where
    F: Fn() -> Fut,
    Fut: Future<Output = Result<Srv, Err>>,
    Srv: Service<Req>, 
[src]

type Response = Srv::Response

type Error = Srv::Error

type Service = Srv

type Config = Cfg

type InitError = Err

type Future = Fut

impl<F, Fut, Cfg, Srv, Req, Err> ServiceFactory<Req> for FnServiceConfig<F, Fut, Cfg, Srv, Req, Err> where
    F: Fn(Cfg) -> Fut,
    Fut: Future<Output = Result<Srv, Err>>,
    Srv: Service<Req>, 
[src]

type Response = Srv::Response

type Error = Srv::Error

type Config = Cfg

type Service = Srv

type InitError = Err

type Future = Fut

impl<F, Fut, Req, Res, Err, Cfg> ServiceFactory<Req> for FnServiceFactory<F, Fut, Req, Res, Err, Cfg> where
    F: FnMut(Req) -> Fut + Clone,
    Fut: Future<Output = Result<Res, Err>>, 
[src]

type Response = Res

type Error = Err

type Config = Cfg

type Service = FnService<F, Fut, Req, Res, Err>

type InitError = ()

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

impl<SF, Cfg, Req> ServiceFactory<Req> for UnitConfig<SF, Cfg, Req> where
    SF: ServiceFactory<Req, Config = ()>, 
[src]

type Response = SF::Response

type Error = SF::Error

type Config = Cfg

type Service = SF::Service

type InitError = SF::InitError

type Future = SF::Future

impl<SF, F, Fut, Req, In, Res, Err> ServiceFactory<Req> for ApplyFactory<SF, F, Req, In, Res, Err> where
    SF: ServiceFactory<In, Error = Err>,
    F: FnMut(Req, &mut SF::Service) -> Fut + Clone,
    Fut: Future<Output = Result<Res, Err>>, 
[src]

type Response = Res

type Error = Err

type Config = SF::Config

type Service = Apply<SF::Service, F, Req, In, Res, Err>

type InitError = SF::InitError

type Future = ApplyServiceFactoryResponse<SF, F, Fut, Req, In, Res, Err>

impl<SF, Req> ServiceFactory<Req> for PipelineFactory<SF, Req> where
    SF: ServiceFactory<Req>, 
[src]

type Config = SF::Config

type Response = SF::Response

type Error = SF::Error

type Service = SF::Service

type InitError = SF::InitError

type Future = SF::Future

impl<SF, Req, F, Cfg> ServiceFactory<Req> for MapConfig<SF, Req, F, Cfg> where
    SF: ServiceFactory<Req>,
    F: Fn(Cfg) -> SF::Config
[src]

type Response = SF::Response

type Error = SF::Error

type Config = Cfg

type Service = SF::Service

type InitError = SF::InitError

type Future = SF::Future

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

type Response = T::Response

type Error = T::Error

type Config = S::Config

type Service = T::Transform

type InitError = T::InitError

type Future = ApplyTransformFuture<T, S, Req>

Loading content...