1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

remove more MessageBody constraints from Response

This commit is contained in:
Nikolay Kim 2019-03-05 18:14:30 -08:00
parent 0d2116156a
commit 496ee8d039

View File

@ -212,7 +212,7 @@ impl<B> Response<B> {
} }
/// Set a body /// Set a body
pub(crate) fn set_body<B2: MessageBody>(self, body: B2) -> Response<B2> { pub(crate) fn set_body<B2>(self, body: B2) -> Response<B2> {
Response { Response {
head: self.head, head: self.head,
body: ResponseBody::Body(body), body: ResponseBody::Body(body),
@ -230,10 +230,7 @@ impl<B> Response<B> {
} }
/// Set a body and return previous body value /// Set a body and return previous body value
pub(crate) fn replace_body<B2: MessageBody>( pub(crate) fn replace_body<B2>(self, body: B2) -> (Response<B2>, ResponseBody<B>) {
self,
body: B2,
) -> (Response<B2>, ResponseBody<B>) {
( (
Response { Response {
head: self.head, head: self.head,
@ -245,7 +242,7 @@ impl<B> Response<B> {
} }
/// Set a body and return previous body value /// Set a body and return previous body value
pub fn map_body<F, B2: MessageBody>(mut self, f: F) -> Response<B2> pub fn map_body<F, B2>(mut self, f: F) -> Response<B2>
where where
F: FnOnce(&mut ResponseHead, ResponseBody<B>) -> ResponseBody<B2>, F: FnOnce(&mut ResponseHead, ResponseBody<B>) -> ResponseBody<B2>,
{ {
@ -597,7 +594,7 @@ impl ResponseBuilder {
/// Set a body and generate `Response`. /// Set a body and generate `Response`.
/// ///
/// `ResponseBuilder` can not be used after this call. /// `ResponseBuilder` can not be used after this call.
pub fn message_body<B: MessageBody>(&mut self, body: B) -> Response<B> { pub fn message_body<B>(&mut self, body: B) -> Response<B> {
if let Some(e) = self.err.take() { if let Some(e) = self.err.take() {
return Response::from(Error::from(e)).into_body(); return Response::from(Error::from(e)).into_body();
} }