Remove boxing from StreamBody (#241)

I just had a thought: Why should `response::Headers` be generic, but
`body::StreamBody` should not? `StreamBody` previously boxed the stream
to erase the generics. So we had `response::Headers<T>` but
`body::StreamBody`, without generics.

After thinking about it I think it actually makes sense for responses to
remain generic because you're able to use `impl IntoResponse` so you
don't have to name the generics.

Whereas in the case of `BodyStream` (an extractor) you cannot use `impl Trait`
so it makes sense to box the inner body to make the type easier to name. Besides,
`BodyStream` is mostly useful when the request body isn't `hyper::Body`, as
that already implements `Stream`.
This commit is contained in:
David Pedersen
2021-08-22 22:03:56 +02:00
committed by GitHub
parent b75c34b821
commit a753eac23f
4 changed files with 113 additions and 58 deletions
-1
View File
@@ -198,7 +198,6 @@ macro_rules! impl_into_response_for_body {
impl_into_response_for_body!(hyper::Body);
impl_into_response_for_body!(Full<Bytes>);
impl_into_response_for_body!(Empty<Bytes>);
impl_into_response_for_body!(crate::body::StreamBody);
impl<E> IntoResponse for http_body::combinators::BoxBody<Bytes, E>
where