pub trait NewService<Request> {
type Response;
type Error;
type Service: Service<Request, Response = Self::Response, Error = Self::Error>;
type InitError;
type Future: Future<Item = Self::Service, Error = Self::InitError>;
fn new_service(&self) -> Self::Future;
fn apply<T, I, F, Out, Req>(
self,
service: I,
f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>>
where
Self: Sized,
T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
I: IntoNewService<T, Req>,
F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
Out: IntoFuture<Error = Self::Error>,
{ ... }
fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B>
where
Self: Sized,
F: IntoNewService<B, Self::Response>,
B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>,
{ ... }
fn from_err<E>(self) -> FromErrNewService<Self, E>
where
Self: Sized,
E: From<Self::Error>,
{ ... }
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B>
where
Self: Sized,
F: IntoNewService<B, Result<Self::Response, Self::Error>>,
B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>,
{ ... }
fn map<F, R>(self, f: F) -> MapNewService<Self, F, R>
where
Self: Sized,
F: Fn(Self::Response) -> R,
{ ... }
fn map_err<F, E>(self, f: F) -> MapErrNewService<Self, F, E>
where
Self: Sized,
F: Fn(Self::Error) -> E,
{ ... }
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E>
where
Self: Sized,
F: Fn(Self::InitError) -> E,
{ ... }
}
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 servier listener. The listner
accepts new TCP streams, obtains a new Service
value using the
NewService
trait, and uses that new Service
value to process inbound
requests on that new TCP stream.
Request - request handled by the service
Responses given by the service
Errors produced by the service
The Service
value created by this factory
Errors produced while building a service.
The future of the Service
instance.
Loading content...
Create and return a new service value asynchronously.
Loading content...
Apply function to specified service and use it as a next service in
chain.
Call another service after call to this one has resolved successfully.
NewService
that create service to map this service's error
and new service's init error to any error
implementing From
for this services
Error`.
Note that this function consumes the receiving new service and returns a
wrapped version of it.
Create NewService
to chain on a computation for when a call to the
service finished, passing the result of the call to the next
service B
.
Note that this function consumes the receiving future and returns a
wrapped version of it.
fn map<F, R>(self, f: F) -> MapNewService<Self, F, R> where
Self: Sized,
F: Fn(Self::Response) -> R,
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.
Map this service's init error to a different error, returning a new service.
Loading content...
type Future = AndThenNewServiceFuture<A, B, Request>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
type Future = ThenNewServiceFuture<A, B, Request>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
type Future = FromErrNewServiceFuture<A, E, Request>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
type Future = MapErrNewServiceFuture<A, F, E, Request>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
type Future = MapInitErrFuture<A, F, E, Request>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
type Future = MapNewServiceFuture<A, F, Request, Response>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
impl<F, R, E, S, Request> NewService<Request> for F where F: Fn() -> R, R: IntoFuture<Item = S, Error = E>, S: Service<Request>, | [src] |
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
impl<F, Req, Resp, Err, Fut> NewService<Req> for FnNewService<F, Req, Resp, Err, Fut> where F: FnMut(Req) -> Fut + Clone, Fut: IntoFuture<Item = Resp, Error = Err>, | [src] |
type Error = Err
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request> where T: NewService<Request>, F: Fn(In, &mut T::Service) -> Out + Clone, Out: IntoFuture, Out::Error: From<T::Error>, | [src] |
type Future = ApplyNewServiceFuture<T, F, In, Out, Request>
fn apply<T, I, F, Out, Req>( self, service: I, f: F ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where Self: Sized, T: NewService<Req, InitError = Self::InitError, Error = Self::Error>, I: IntoNewService<T, Req>, F: Fn(Self::Response, &mut T::Service) -> Out + Clone, Out: IntoFuture<Error = Self::Error>, | [src] |
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where Self: Sized, F: IntoNewService<B, Result<Self::Response, Self::Error>>, B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, | [src] |
Loading content...