[−][src]Trait kayrx::service::ServiceFactory
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<Request = Self::Request, Response = Self::Response, Error = Self::Error>
The Service
value created by this factory
type InitError
Errors produced while building a service.
type Future: Future<Output = Result<Self::Service, Self::InitError>>
The future of the Service
instance.
Required methods
fn new_service(&self, cfg: Self::Config) -> Self::Future
Create and return a new service value asynchronously.
Provided methods
fn map<F, R>(self, f: F) -> MapServiceFactory<Self, F, R> where
Self: Sized,
F: FnMut(Self::Response) -> R + Clone,
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,
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,
Self: Sized,
F: Fn(Self::InitError) -> E + Clone,
Map this factory's init error to a different error, returning a new service.
Implementations on Foreign Types
impl<S> ServiceFactory for Rc<S> where
S: ServiceFactory,
[src]
S: ServiceFactory,
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
fn new_service(&self, cfg: S::Config) -> S::Future
[src]
impl<S> ServiceFactory for Arc<S> where
S: ServiceFactory,
[src]
S: ServiceFactory,
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
fn new_service(&self, cfg: S::Config) -> S::Future
[src]
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>>
fn new_service(&self, _: ()) -> Self::Future
[src]
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>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl ServiceFactory for Route
[src]
type Config = ()
type Request = ServiceRequest
type Response = ServiceResponse
type Error = Error
type InitError = ()
type Service = RouteService
type Future = CreateRouteService
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<A, B> ServiceFactory for AndThenServiceFactory<A, B> where
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Request = A::Response, Error = A::Error, InitError = A::InitError>,
[src]
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Request = A::Response, Error = A::Error, InitError = A::InitError>,
type Request = A::Request
type Response = B::Response
type Error = A::Error
type Config = A::Config
type Service = AndThenService<A::Service, B::Service>
type InitError = A::InitError
type Future = AndThenServiceFactoryResponse<A, B>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<A, B> ServiceFactory for ThenServiceFactory<A, B> where
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Request = Result<A::Response, A::Error>, Error = A::Error, InitError = A::InitError>,
[src]
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Request = Result<A::Response, A::Error>, Error = A::Error, InitError = A::InitError>,
type Request = A::Request
type Response = B::Response
type Error = A::Error
type Config = A::Config
type Service = ThenService<A::Service, B::Service>
type InitError = A::InitError
type Future = ThenServiceFactoryResponse<A, B>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
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]
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, Response = A::Response, Error = A::Error, InitError = A::InitError>,
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>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<A, B, F, Fut, Res, Err> ServiceFactory for AndThenApplyFnFactory<A, B, F, Fut, Res, Err> where
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, InitError = A::InitError>,
F: FnMut(A::Response, &mut B::Service) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
Err: From<A::Error> + From<B::Error>,
[src]
A: ServiceFactory,
A::Config: Clone,
B: ServiceFactory<Config = A::Config, InitError = A::InitError>,
F: FnMut(A::Response, &mut B::Service) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
Err: From<A::Error> + From<B::Error>,
type Request = A::Request
type Response = Res
type Error = Err
type Service = AndThenApplyFn<A::Service, B::Service, F, Fut, Res, Err>
type Config = A::Config
type InitError = A::InitError
type Future = AndThenApplyFnFactoryResponse<A, B, F, Fut, Res, Err>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<A, C> ServiceFactory for UnitConfig<A, C> where
A: ServiceFactory<Config = ()>,
[src]
A: ServiceFactory<Config = ()>,
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
fn new_service(&self, _: C) -> Self::Future
[src]
impl<A, F, C> ServiceFactory for MapConfig<A, F, C> where
A: ServiceFactory,
F: Fn(C) -> A::Config,
[src]
A: ServiceFactory,
F: Fn(C) -> A::Config,
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
fn new_service(&self, cfg: C) -> Self::Future
[src]
impl<A, F, E> ServiceFactory for MapErrServiceFactory<A, F, E> where
A: ServiceFactory,
F: Fn(A::Error) -> E + Clone,
[src]
A: ServiceFactory,
F: Fn(A::Error) -> E + Clone,
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>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<A, F, E> ServiceFactory for MapInitErr<A, F, E> where
A: ServiceFactory,
F: Fn(A::InitError) -> E + Clone,
[src]
A: ServiceFactory,
F: Fn(A::InitError) -> E + Clone,
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>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<A, F, Res> ServiceFactory for MapServiceFactory<A, F, Res> where
A: ServiceFactory,
F: FnMut(A::Response) -> Res + Clone,
[src]
A: ServiceFactory,
F: FnMut(A::Response) -> Res + Clone,
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>
fn new_service(&self, cfg: A::Config) -> Self::Future
[src]
impl<C, Req, Res, Err, InitErr> ServiceFactory for BoxServiceFactory<C, Req, Res, Err, InitErr> where
Req: 'static,
Res: 'static,
Err: 'static,
InitErr: 'static,
[src]
Req: 'static,
Res: 'static,
Err: 'static,
InitErr: 'static,
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>
fn new_service(&self, cfg: C) -> Self::Future
[src]
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]
F: Fn() -> R,
R: Future<Output = Result<S, E>>,
S: Service,
type Request = S::Request
type Response = S::Response
type Error = S::Error
type Service = S
type Config = C
type InitError = E
type Future = R
fn new_service(&self, _: C) -> Self::Future
[src]
impl<F, C, T, R, S> ServiceFactory for ApplyConfigServiceFactory<F, C, T, R, S> where
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
S: Service,
[src]
F: FnMut(C, &mut T::Service) -> R,
T: ServiceFactory<Config = ()>,
T::InitError: From<T::Error>,
R: Future<Output = Result<S, T::InitError>>,
S: Service,
type Config = C
type Request = S::Request
type Response = S::Response
type Error = S::Error
type Service = S
type InitError = T::InitError
type Future = ApplyConfigServiceFactoryResponse<F, C, T, R, S>
fn new_service(&self, cfg: C) -> Self::Future
[src]
impl<F, C, T, R, S, E> ServiceFactory for ApplyConfigService<F, C, T, R, S, E> where
F: FnMut(C, &mut T) -> R,
T: Service,
R: Future<Output = Result<S, E>>,
S: Service,
[src]
F: FnMut(C, &mut T) -> R,
T: Service,
R: Future<Output = Result<S, E>>,
S: Service,
type Config = C
type Request = S::Request
type Response = S::Response
type Error = S::Error
type Service = S
type InitError = E
type Future = R
fn new_service(&self, cfg: C) -> Self::Future
[src]
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]
F: Fn(Cfg) -> Fut,
Fut: Future<Output = Result<Srv, Err>>,
Srv: Service,
type Request = Srv::Request
type Response = Srv::Response
type Error = Srv::Error
type Config = Cfg
type Service = Srv
type InitError = Err
type Future = Fut
fn new_service(&self, cfg: Cfg) -> Self::Future
[src]
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]
F: FnMut(Req) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>,
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>>
fn new_service(&self, _: Cfg) -> Self::Future
[src]
impl<R, E, F> ServiceFactory for KeepAlive<R, E, F> where
F: Fn() -> E + Clone,
[src]
F: Fn() -> E + Clone,
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>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T> ServiceFactory for OneRequest<T> where
T: AsyncRead + AsyncWrite + Unpin,
[src]
T: AsyncRead + AsyncWrite + Unpin,
type Config = ()
type Request = T
type Response = (Request, Framed<T, Codec>)
type Error = ParseError
type InitError = ()
type Service = OneRequestService<T>
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
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>>
fn new_service(&self, _: ()) -> Self::Future
[src]
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]
T: ServiceFactory<Error = Err>,
F: FnMut(In, &mut T::Service) -> R + Clone,
R: Future<Output = Result<Out, Err>>,
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>
fn new_service(&self, cfg: T::Config) -> Self::Future
[src]
impl<T, S> ServiceFactory for ApplyTransform<T, S> where
S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>,
[src]
S: ServiceFactory,
T: Transform<S::Service, InitError = S::InitError>,
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>
fn new_service(&self, cfg: S::Config) -> Self::Future
[src]
impl<T, S, B> ServiceFactory for H2Service<T, S, B> where
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: Into<Error> + 'static,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
B: MessageBody + 'static,
[src]
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: Into<Error> + 'static,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
B: MessageBody + 'static,
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>
fn new_service(&self, _: ()) -> Self::Future
[src]
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: Into<Error>,
S::Response: Into<Response<B>>,
S::InitError: Debug,
B: MessageBody,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: Into<Error>,
X::InitError: Debug,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + Into<Error>,
U::InitError: Debug,
[src]
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: Into<Error>,
S::Response: Into<Response<B>>,
S::InitError: Debug,
B: MessageBody,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: Into<Error>,
X::InitError: Debug,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + Into<Error>,
U::InitError: Debug,
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>
fn new_service(&self, _: ()) -> Self::Future
[src]
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: Into<Error> + 'static,
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: Into<Error>,
X::InitError: Debug,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + Into<Error>,
U::InitError: Debug,
<U::Service as Service>::Future: 'static,
[src]
T: AsyncRead + AsyncWrite + Unpin,
S: ServiceFactory<Config = (), Request = Request>,
S::Error: Into<Error> + 'static,
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: Into<Error>,
X::InitError: Debug,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display + Into<Error>,
U::InitError: Debug,
<U::Service as Service>::Future: 'static,
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>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T: Address> ServiceFactory for ConnectServiceFactory<T>
[src]
type Request = Connect<T>
type Response = Connection<T, TcpStream>
type Error = ConnectError
type Config = ()
type Service = ConnectService<T>
type InitError = ()
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T: Address> ServiceFactory for ResolverFactory<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>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T: Address> ServiceFactory for TcpConnectorFactory<T>
[src]
type Request = Connect<T>
type Response = Connection<T, TcpStream>
type Error = ConnectError
type Config = ()
type Service = TcpConnector<T>
type InitError = ()
type Future = Ready<Result<Self::Service, Self::InitError>>
fn new_service(&self, _: ()) -> Self::Future
[src]
impl<T: Address, U> ServiceFactory for RustlsConnector<T, U> where
U: AsyncRead + AsyncWrite + Unpin + Debug,
[src]
U: AsyncRead + AsyncWrite + Unpin + Debug,