pub trait ResponseHandler {
// Required methods
fn on_response(&mut self, response: &Parts);
fn on_service_error<E>(&mut self, error: &E)
where E: Display + 'static;
// Provided methods
fn on_body_chunk<B>(&mut self, _chunk: &B)
where B: Buf { ... }
fn on_end_of_stream(&mut self, _trailers: Option<&HeaderMap>) { ... }
fn on_body_error<E>(&mut self, _error: &E)
where E: Display + 'static { ... }
}Expand description
Observes the response as seen by the caller: the response parts, the
response body, and the service-level error that occurs if the inner
service’s future resolves to Err before any response is produced.
Body-level methods default to no-ops.
Required Methods§
Sourcefn on_response(&mut self, response: &Parts)
fn on_response(&mut self, response: &Parts)
Called exactly once when the inner service produces a response.
Sourcefn on_service_error<E>(&mut self, error: &E)where
E: Display + 'static,
fn on_service_error<E>(&mut self, error: &E)where
E: Display + 'static,
Called when the inner service’s future resolves to Err (no
response is produced). Response body errors are reported
separately through Self::on_body_error.
Provided Methods§
Sourcefn on_body_chunk<B>(&mut self, _chunk: &B)where
B: Buf,
fn on_body_chunk<B>(&mut self, _chunk: &B)where
B: Buf,
Called once per data frame yielded by the response body.
Sourcefn on_end_of_stream(&mut self, _trailers: Option<&HeaderMap>)
fn on_end_of_stream(&mut self, _trailers: Option<&HeaderMap>)
Called at most once when the response body stream ends.
Sourcefn on_body_error<E>(&mut self, _error: &E)where
E: Display + 'static,
fn on_body_error<E>(&mut self, _error: &E)where
E: Display + 'static,
Called when polling the response body yields an error.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.