pub trait Svc<Req> {
type Res;
type Fut: Future<Output = Self::Res>;
// Required method
fn exec(self: Pin<&mut Self>, req: Req) -> Self::Fut;
// Provided method
fn poll_ready(self: Pin<&mut Self>, cx: Context<'_>) -> Poll<()> { ... }
}
Expand description
Service trait representing an asynchronous request/response operation.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn poll_ready(self: Pin<&mut Self>, cx: Context<'_>) -> Poll<()>
fn poll_ready(self: Pin<&mut Self>, cx: Context<'_>) -> Poll<()>
To be called before exec
to signal wether the service is ready to process requests.
As such, the check should be inexpensive. Returning Poll::Pending
acts as back-pressure.
The default implementation unconditionally indicates the service is ready.