Trait actix_service::Service
source · pub trait Service<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: Request) -> Self::Future;
}Expand description
An asynchronous function from Request to a Response.
Required Associated Types§
Required Methods§
sourcefn poll_ready(&mut self) -> Poll<(), Self::Error>
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.
sourcefn call(&mut self, req: Request) -> Self::Future
fn call(&mut self, req: 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.