Trait tower_make::MakeService[][src]

pub trait MakeService<Target, Request>: Sealed<(Target, Request)> {
    type Response;
    type Error;
    type Service: Service<Request, Response = Self::Response, Error = Self::Error>;
    type MakeError;
    type Future: Future<Output = Result<Self::Service, Self::MakeError>>;
    fn poll_ready(
        &mut self,
        cx: &mut Context<'_>
    ) -> Poll<Result<(), Self::MakeError>>;
fn make_service(&mut self, target: Target) -> Self::Future; }

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 MakeService trait, and uses that new Service value to process inbound requests on that new TCP stream.

This is essentially a trait alias for a Service of Services.

Associated Types

type Response[src]

Responses given by the service

type Error[src]

Errors produced by the service

type Service: Service<Request, Response = Self::Response, Error = Self::Error>[src]

The Service value created by this factory

type MakeError[src]

Errors produced while building a service.

type Future: Future<Output = Result<Self::Service, Self::MakeError>>[src]

The future of the Service instance.

Loading content...

Required methods

fn poll_ready(
    &mut self,
    cx: &mut Context<'_>
) -> Poll<Result<(), Self::MakeError>>
[src]

Returns Ready when the factory is able to create more services.

If the service is at capacity, then Poll::Pending is returned and the task is notified when the service becomes ready again. This function is expected to be called while on a task.

fn make_service(&mut self, target: Target) -> Self::Future[src]

Create and return a new service value asynchronously.

Loading content...

Implementors

impl<M, S, Target, Request> MakeService<Target, Request> for M where
    M: Service<Target, Response = S>,
    S: Service<Request>, 
[src]

type Response = S::Response

type Error = S::Error

type Service = S

type MakeError = M::Error

type Future = M::Future

Loading content...