rename boxbody from_body to new

This commit is contained in:
Rob Ede 2021-11-23 16:11:49 +00:00
parent a2d5c5a058
commit 25e3867b1d
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 7 additions and 4 deletions

View File

@ -4,8 +4,10 @@
### Added ### Added
* Add timeout for canceling HTTP/2 server side connection handshake. Default to 5 seconds. [#2483] * Add timeout for canceling HTTP/2 server side connection handshake. Default to 5 seconds. [#2483]
* HTTP/2 handshake timeout can be configured with `ServiceConfig::client_timeout`. [#2483] * HTTP/2 handshake timeout can be configured with `ServiceConfig::client_timeout`. [#2483]
* Rename `body::BoxBody::{from_body => new}`. [#????]
[#2483]: https://github.com/actix/actix-web/pull/2483 [#2483]: https://github.com/actix/actix-web/pull/2483
[#????]: https://github.com/actix/actix-web/pull/????
## 3.0.0-beta.14 - 2021-11-30 ## 3.0.0-beta.14 - 2021-11-30
### Changed ### Changed

View File

@ -14,6 +14,7 @@ use crate::error::Error;
use super::{BodySize, BodyStream, MessageBody, MessageBodyMapErr, SizedStream}; use super::{BodySize, BodyStream, MessageBody, MessageBodyMapErr, SizedStream};
/// (Deprecated) Represents various types of HTTP message body.
#[deprecated(since = "4.0.0", note = "Renamed to `AnyBody`.")] #[deprecated(since = "4.0.0", note = "Renamed to `AnyBody`.")]
pub type Body = AnyBody; pub type Body = AnyBody;
@ -48,7 +49,7 @@ impl AnyBody {
B: MessageBody + 'static, B: MessageBody + 'static,
B::Error: Into<Box<dyn StdError + 'static>>, B::Error: Into<Box<dyn StdError + 'static>>,
{ {
Self::Body(BoxBody::from_body(body)) Self::Body(BoxBody::new(body))
} }
/// Constructs new `AnyBody` instance from a slice of bytes by copying it. /// Constructs new `AnyBody` instance from a slice of bytes by copying it.
@ -242,7 +243,7 @@ pub struct BoxBody(Pin<Box<dyn MessageBody<Error = Box<dyn StdError>>>>);
impl BoxBody { impl BoxBody {
/// Boxes a `MessageBody` and any errors it generates. /// Boxes a `MessageBody` and any errors it generates.
pub fn from_body<B>(body: B) -> Self pub fn new<B>(body: B) -> Self
where where
B: MessageBody + 'static, B: MessageBody + 'static,
B::Error: Into<Box<dyn StdError + 'static>>, B::Error: Into<Box<dyn StdError + 'static>>,
@ -323,7 +324,7 @@ mod tests {
#[actix_rt::test] #[actix_rt::test]
async fn nested_boxed_body() { async fn nested_boxed_body() {
let body = AnyBody::copy_from_slice(&[1, 2, 3]); let body = AnyBody::copy_from_slice(&[1, 2, 3]);
let boxed_body = BoxBody::from_body(BoxBody::from_body(body)); let boxed_body = BoxBody::new(BoxBody::new(body));
assert_eq!( assert_eq!(
to_bytes(boxed_body).await.unwrap(), to_bytes(boxed_body).await.unwrap(),