[][src]Trait actix_service::Service

pub trait Service {
    type Request;
    type Response;
    type Error;
    type Future: Future<Item = Self::Response, Error = Self::Error>;
    fn poll_ready(&mut self) -> Poll<(), 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<Item = Self::Response, Error = Self::Error>

The future response value.

Loading content...

Required methods

fn poll_ready(&mut self) -> Poll<(), 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<'a, S> Service for &'a mut S where
    S: Service + 'a, 
[src]

type Request = S::Request

type Response = S::Response

type Error = S::Error

type Future = S::Future

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

type Request = S::Request

type Response = S::Response

type Error = S::Error

type Future = S::Future

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

type Request = S::Request

type Response = S::Response

type Error = S::Error

type Future = S::Future

Loading content...

Implementors

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

type Request = A::Request

type Response = B::Response

type Error = A::Error

type Future = AndThenFuture<A, B>

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

type Request = A::Request

type Response = B::Response

type Error = B::Error

type Future = ThenFuture<A, B>

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

type Request = A::Request

type Response = A::Response

type Error = E

type Future = FromErrFuture<A, E>

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

type Request = A::Request

type Response = A::Response

type Error = E

type Future = MapErrFuture<A, F, E>

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

type Request = A::Request

type Response = Response

type Error = A::Error

type Future = MapFuture<A, F, Response>

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

type Request = Req

type Response = Out::Item

type Error = Out::Error

type Future = Out::Future

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

type Request = R

type Response = R

type Error = E

type Future = FutureResult<R, E>

Loading content...