mirror of https://github.com/fafhrd91/actix-web
rename boxbody from_body to new
This commit is contained in:
parent
a2d5c5a058
commit
25e3867b1d
|
@ -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
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
Loading…
Reference in New Issue