[][src]Trait actix_service::ServiceFactory

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

    fn map<F, R>(self, f: F) -> MapServiceFactory<Self, F, R>
    where
        Self: Sized,
        F: FnMut(Self::Response) -> R + Clone
, { ... }
fn map_err<F, E>(self, f: F) -> MapErrServiceFactory<Self, F, E>
    where
        Self: Sized,
        F: Fn(Self::Error) -> E + Clone
, { ... }
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E>
    where
        Self: Sized,
        F: Fn(Self::InitError) -> E + Clone
, { ... } }

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 Request

Requests handled by the created services.

type Response

Responses given by the created services.

type Error

Errors produced by the created services.

type Config

Service factory configuration.

type Service: Service<Request = Self::Request, Response = Self::Response, Error = Self::Error>

The kind of Service created by this factory.

type InitError

Errors potentially raised while building a service.

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

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

Loading content...

Provided methods

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

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> ServiceFactory for Arc<S> where
    S: ServiceFactory
[src]

type Request = S::Request

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, C> ServiceFactory for UnitConfig<A, C> where
    A: ServiceFactory<Config = ()>, 
[src]

type Request = A::Request

type Response = A::Response

type Error = A::Error

type Config = C

type Service = A::Service

type InitError = A::InitError

type Future = A::Future

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

type Request = A::Request

type Response = A::Response

type Error = A::Error

type Config = C

type Service = A::Service

type InitError = A::InitError

type Future = A::Future

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

type Request = A::Request

type Response = A::Response

type Error = E

type Config = A::Config

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

type InitError = A::InitError

type Future = MapErrServiceFuture<A, F, E>

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

type Request = A::Request

type Response = A::Response

type Error = A::Error

type Config = A::Config

type Service = A::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::Response) -> Res + Clone
[src]

type Request = A::Request

type Response = Res

type Error = A::Error

type Config = A::Config

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

type InitError = A::InitError

type Future = MapServiceFuture<A, F, Res>

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

type Request = Req

type Response = Res

type Error = Err

type InitError = InitErr

type Config = C

type Service = BoxService<Req, Res, Err>

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

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

type Response = S::Response

type Error = S::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::Request

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 for FnServiceFactory<F, Fut, Req, Res, Err, Cfg> where
    F: FnMut(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<Self::Service, Self::InitError>>

impl<T, F, R, In, Out, Err> ServiceFactory for ApplyServiceFactory<T, F, R, In, Out, Err> where
    T: ServiceFactory<Error = Err>,
    F: FnMut(In, &mut T::Service) -> R + Clone,
    R: Future<Output = Result<Out, Err>>, 
[src]

type Request = In

type Response = Out

type Error = Err

type Config = T::Config

type Service = Apply<T::Service, F, R, In, Out, Err>

type InitError = T::InitError

type Future = ApplyServiceFactoryResponse<T, F, R, In, Out, Err>

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

type Request = T::Request

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>

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

type Config = T::Config

type Request = T::Request

type Response = T::Response

type Error = T::Error

type Service = T::Service

type InitError = T::InitError

type Future = T::Future

Loading content...