Trait ntex_service::ServiceFactory
source · [−]pub trait ServiceFactory<Req, Cfg = ()> {
type Response;
type Error;
type Service: Service<Req, Response = Self::Response, Error = Self::Error>;
type InitError;
type Future: Future<Output = Result<Self::Service, Self::InitError>>;
fn new_service(&self, cfg: Cfg) -> Self::Future;
fn map<F, Res>(self, f: F) -> MapServiceFactory<Self, F, Req, Res, Cfg>
where
Self: Sized,
F: FnMut(Self::Response) -> Res + Clone,
{ ... }
fn map_err<F, E>(self, f: F) -> MapErrServiceFactory<Self, Req, Cfg, F, E>
where
Self: Sized,
F: Fn(Self::Error) -> E + Clone,
{ ... }
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, Req, Cfg, F, E>
where
Self: Sized,
F: Fn(Self::InitError) -> E + Clone,
{ ... }
}Expand description
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.
Required Associated Types
The Service value created by this factory
Required Methods
fn new_service(&self, cfg: Cfg) -> Self::Future
fn new_service(&self, cfg: Cfg) -> Self::Future
Create and return a new service value asynchronously.
Provided Methods
Map this service’s output to a different type, returning a new service of the resulting type.
Map this service’s error to a different error, returning a new service.
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, Req, Cfg, F, E> where
Self: Sized,
F: Fn(Self::InitError) -> E + Clone,
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, Req, Cfg, 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.