actix_service

Trait ServiceFactory

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

    // Required method
    fn new_service(&self, cfg: Self::Config) -> Self::Future;
}
Expand description

Factory for creating Services.

This is useful for cases where new Services must be produced. One case is a TCP server listener: a listener accepts new connections, constructs a new Service for each using the ServiceFactory trait, and uses the new Service to process inbound requests on that new connection.

Config is a service factory configuration type.

Simple factories may be able to use fn_factory or fn_factory_with_config to reduce boilerplate.

Required Associated Types§

Source

type Response

Responses given by the created services.

Source

type Error

Errors produced by the created services.

Source

type Config

Service factory configuration.

Source

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

The kind of Service created by this factory.

Source

type InitError

Errors potentially raised while building a service.

Source

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

The future of the Service instance.g

Required Methods§

Source

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

Create and return a new service asynchronously.

Implementations on Foreign Types§

Source§

impl<S, Req> ServiceFactory<Req> for Rc<S>
where S: ServiceFactory<Req>,

Source§

impl<S, Req> ServiceFactory<Req> for Arc<S>
where S: ServiceFactory<Req>,

Implementors§

Source§

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

Source§

type Response = Res

Source§

type Error = Err

Source§

type Config = C

Source§

type Service = Box<dyn Service<Req, Error = Err, Response = Res, Future = Pin<Box<dyn Future<Output = Result<Res, Err>>>>>>

Source§

type InitError = InitErr

Source§

type Future = Pin<Box<dyn Future<Output = Result<<BoxServiceFactory<C, Req, Res, Err, InitErr> as ServiceFactory<Req>>::Service, InitErr>>>>

Source§

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

Source§

type Response = <T as Transform<<S as ServiceFactory<Req>>::Service, Req>>::Response

Source§

type Error = <T as Transform<<S as ServiceFactory<Req>>::Service, Req>>::Error

Source§

type Config = <S as ServiceFactory<Req>>::Config

Source§

type Service = <T as Transform<<S as ServiceFactory<Req>>::Service, Req>>::Transform

Source§

type InitError = <T as Transform<<S as ServiceFactory<Req>>::Service, Req>>::InitError

Source§

type Future = ApplyTransformFuture<T, S, Req>