[][src]Trait actix_web::dev::Service

pub trait Service where
    <Self::Future as Future>::Item == Self::Response,
    <Self::Future as Future>::Error == Self::Error
{ type Request; type Response; type Error; type Future: Future; fn poll_ready(&mut self) -> Result<Async<()>, Self::Error>;
fn call(&mut self, req: Self::Request) -> Self::Future; }

An asynchronous function from Request to a Response.

Associated Types

type Request

Requests handled by the service.

type Response

Responses given by the service.

type Error

Errors produced by the service.

type Future: Future

The future response value.

Loading content...

Required methods

fn poll_ready(&mut self) -> Result<Async<()>, Self::Error>

Returns Ready when the service is able to process requests.

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

This is a best effort implementation. False positives are permitted. It is permitted for the service to return Ready from a poll_ready call and the next invocation of call results in an error.

fn call(&mut self, req: Self::Request) -> Self::Future

Process the request and return the response asynchronously.

This function is expected to be callable off task. As such, implementations should take care to not call poll_ready. If the service is at capacity and the request is unable to be handled, the returned Future should resolve to an error.

Calling call without calling poll_ready is permitted. The implementation must be resilient to this fact.

Loading content...

Implementations on Foreign Types

impl Service for ExpectHandler[src]

type Request = Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>

type Response = Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>

type Error = Error

type Future = FutureResult<<ExpectHandler as Service>::Response, <ExpectHandler as Service>::Error>

impl<T, P, S, B, X, U> Service for H1ServiceHandler<T, P, S, B, X, U> where
    B: MessageBody,
    S: Service<Request = Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>>,
    T: IoStream,
    U: Service<Request = (Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>, Framed<T, Codec>), Response = ()>,
    X: Service<Request = Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>, Response = Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>>,
    <S as Service>::Error: Into<Error>,
    <S as Service>::Response: Into<Response<B>>,
    <X as Service>::Error: Into<Error>,
    <U as Service>::Error: Display
[src]

type Request = Io<T, P>

type Response = ()

type Error = DispatchError

type Future = Dispatcher<T, S, B, X, U>

impl<T> Service for UpgradeHandler<T>[src]

type Request = (Request<Box<dyn Stream<Item = Bytes, Error = PayloadError> + 'static>>, Framed<T, Codec>)

type Response = ()

type Error = Error

type Future = FutureResult<<UpgradeHandler<T> as Service>::Response, <UpgradeHandler<T> as Service>::Error>

impl<A, F, Response> Service for Map<A, F, Response> where
    A: Service,
    F: FnMut(<A as Service>::Response) -> Response + Clone
[src]

type Request = <A as Service>::Request

type Response = Response

type Error = <A as Service>::Error

type Future = MapFuture<A, F, Response>

impl<'a, S> Service for &'a mut S where
    S: Service + 'a, 
[src]

type Request = <S as Service>::Request

type Response = <S as Service>::Response

type Error = <S as Service>::Error

type Future = <S as Service>::Future

impl<A, F, E> Service for MapErr<A, F, E> where
    A: Service,
    F: Fn(<A as Service>::Error) -> E + Clone
[src]

type Request = <A as Service>::Request

type Response = <A as Service>::Response

type Error = E

type Future = MapErrFuture<A, F, E>

impl<R, E> Service for Blank<R, E>[src]

type Request = R

type Response = R

type Error = E

type Future = FutureResult<R, E>

impl<A, B> Service for AndThen<A, B> where
    A: Service,
    B: Service<Request = <A as Service>::Response, Error = <A as Service>::Error>, 
[src]

type Request = <A as Service>::Request

type Response = <B as Service>::Response

type Error = <A as Service>::Error

type Future = AndThenFuture<A, B>

impl<A, E> Service for FromErr<A, E> where
    A: Service,
    E: From<<A as Service>::Error>, 
[src]

type Request = <A as Service>::Request

type Response = <A as Service>::Response

type Error = E

type Future = FromErrFuture<A, E>

impl<A, B> Service for Then<A, B> where
    A: Service,
    B: Service<Request = Result<<A as Service>::Response, <A as Service>::Error>, Error = <A as Service>::Error>, 
[src]

type Request = <A as Service>::Request

type Response = <B as Service>::Response

type Error = <B as Service>::Error

type Future = ThenFuture<A, B>

impl<S> Service for Rc<RefCell<S>> where
    S: Service
[src]

type Request = <S as Service>::Request

type Response = <S as Service>::Response

type Error = <S as Service>::Error

type Future = <S as Service>::Future

impl<S> Service for Box<S> where
    S: Service + ?Sized
[src]

type Request = <S as Service>::Request

type Response = <S as Service>::Response

type Error = <S as Service>::Error

type Future = <S as Service>::Future

impl<F, Req, Out> Service for ServiceFn<F, Req, Out> where
    F: FnMut(Req) -> Out,
    Out: IntoFuture
[src]

type Request = Req

type Response = <Out as IntoFuture>::Item

type Error = <Out as IntoFuture>::Error

type Future = <Out as IntoFuture>::Future

impl<T> Service for TcpConnector<T> where
    T: Address, 

type Request = Connect<T>

type Response = Connection<T, TcpStream>

type Error = ConnectError

type Future = Either<TcpConnectorResponse<T>, FutureResult<<TcpConnector<T> as Service>::Response, <TcpConnector<T> as Service>::Error>>

impl<T> Service for Resolver<T> where
    T: Address, 

type Request = Connect<T>

type Response = Connect<T>

type Error = ConnectError

type Future = Either<ResolverFuture<T>, FutureResult<Connect<T>, <Resolver<T> as Service>::Error>>

impl<S, T, E> Service for StreamService<S, T, E> where
    S: 'static + IntoStream,
    T: NewService<Request = Result<<S as IntoStream>::Item, <S as IntoStream>::Error>, Response = (), Error = E, InitError = E>,
    <T as NewService>::Future: 'static,
    <T as NewService>::Service: 'static,
    <<T as NewService>::Service as Service>::Future: 'static, 
[src]

type Request = S

type Response = ()

type Error = E

type Future = Box<dyn Future<Item = (), Error = E> + 'static>

impl<R, E, F> Service for KeepAliveService<R, E, F> where
    F: Fn() -> E, 
[src]

type Request = R

type Response = R

type Error = E

type Future = FutureResult<R, E>

impl<S> Service for InOrderService<S> where
    S: Service,
    <S as Service>::Response: 'static,
    <S as Service>::Future: 'static,
    <S as Service>::Error: 'static, 
[src]

type Request = <S as Service>::Request

type Response = <S as Service>::Response

type Error = InOrderError<<S as Service>::Error>

type Future = InOrderServiceResponse<S>

impl<S> Service for TimeoutService<S> where
    S: Service
[src]

type Request = <S as Service>::Request

type Response = <S as Service>::Response

type Error = TimeoutError<<S as Service>::Error>

type Future = TimeoutServiceResponse<S>

impl<T> Service for InFlightService<T> where
    T: Service
[src]

type Request = <T as Service>::Request

type Response = <T as Service>::Response

type Error = <T as Service>::Error

type Future = InFlightServiceResponse<T>

impl Service for LowResTimeService[src]

impl<A, B> Service for EitherService<A, B> where
    A: Service,
    B: Service<Response = <A as Service>::Response, Error = <A as Service>::Error>, 
[src]

type Request = Either<<A as Service>::Request, <B as Service>::Request>

type Response = <A as Service>::Response

type Error = <A as Service>::Error

type Future = Either<<A as Service>::Future, <B as Service>::Future>

Loading content...

Implementors

Loading content...