mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 16:55:08 +02:00
add associated error type to MessageBody (#2183)
This commit is contained in:
@ -113,7 +113,11 @@ pub trait MapServiceResponseBody {
|
||||
fn map_body(self) -> ServiceResponse;
|
||||
}
|
||||
|
||||
impl<B: MessageBody + Unpin + 'static> MapServiceResponseBody for ServiceResponse<B> {
|
||||
impl<B> MapServiceResponseBody for ServiceResponse<B>
|
||||
where
|
||||
B: MessageBody + Unpin + 'static,
|
||||
B::Error: Into<Error>,
|
||||
{
|
||||
fn map_body(self) -> ServiceResponse {
|
||||
self.map_body(|_, body| ResponseBody::Other(Body::from_message(body)))
|
||||
}
|
||||
|
@ -22,10 +22,9 @@ use time::OffsetDateTime;
|
||||
|
||||
use crate::{
|
||||
dev::{BodySize, MessageBody, ResponseBody},
|
||||
error::{Error, Result},
|
||||
http::{HeaderName, StatusCode},
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
HttpResponse,
|
||||
Error, HttpResponse, Result,
|
||||
};
|
||||
|
||||
/// Middleware for logging request and response summaries to the terminal.
|
||||
@ -327,7 +326,13 @@ impl<B> PinnedDrop for StreamLog<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: MessageBody> MessageBody for StreamLog<B> {
|
||||
impl<B> MessageBody for StreamLog<B>
|
||||
where
|
||||
B: MessageBody,
|
||||
B::Error: Into<Error>,
|
||||
{
|
||||
type Error = Error;
|
||||
|
||||
fn size(&self) -> BodySize {
|
||||
self.body.size()
|
||||
}
|
||||
@ -335,7 +340,7 @@ impl<B: MessageBody> MessageBody for StreamLog<B> {
|
||||
fn poll_next(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Option<Result<Bytes, Error>>> {
|
||||
) -> Poll<Option<Result<Bytes, Self::Error>>> {
|
||||
let this = self.project();
|
||||
match this.body.poll_next(cx) {
|
||||
Poll::Ready(Some(Ok(chunk))) => {
|
||||
|
Reference in New Issue
Block a user