pub trait Handler: Sync {
type Error: Error + Send + Sync + 'static;
type Body<B: ReadableBody>: ReadableBody;
// Required method
fn call<B: ReadableBody, I: InterimHandler>(
&self,
request: Request<B>,
interim: &mut InterimResponses<I>,
cancellation: &Cancellation,
) -> impl Future<Output = Result<Response<Self::Body<B>>, Self::Error>> + Send;
}Expand description
Generic bodies and hooks keep handlers independent of the HTTP wire version
and scheduler. A returned body may retain the request body, including borrows.
An error responds with a bodiless status and closes the connection, which then reports it as Error::Handler: 400 when a request read failed, such as a malformed or truncated body, even if the error has another cause, and otherwise 500. Return an ordinary response for other client errors. A final response which HTTP/1 cannot send, such as an informational status, conflicting framing, a Content-Length field its body contradicts or an unsolicited upgrade, likewise receives a bodiless 500 and closes the connection, which reports it as Error::Response.
Required Associated Types§
type Error: Error + Send + Sync + 'static
type Body<B: ReadableBody>: ReadableBody
Required Methods§
fn call<B: ReadableBody, I: InterimHandler>( &self, request: Request<B>, interim: &mut InterimResponses<I>, cancellation: &Cancellation, ) -> impl Future<Output = Result<Response<Self::Body<B>>, Self::Error>> + Send
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".