mirror of https://github.com/fafhrd91/actix-web
ClientResponse does not require Unpin
This commit is contained in:
parent
ca2595bf44
commit
ed832bd008
|
@ -8,7 +8,6 @@
|
||||||
- `impl Future` for `ResponseBody` no longer requires the body type be `Unpin`. [#2546]
|
- `impl Future` for `ResponseBody` no longer requires the body type be `Unpin`. [#2546]
|
||||||
- `impl Future` for `JsonBody` no longer requires the body type be `Unpin`. [#2546]
|
- `impl Future` for `JsonBody` no longer requires the body type be `Unpin`. [#2546]
|
||||||
- `impl Stream` for `ClientResponse` no longer requires the body type be `Unpin`. [#2546]
|
- `impl Stream` for `ClientResponse` no longer requires the body type be `Unpin`. [#2546]
|
||||||
- `ClientResponse` is no longer `Unpin`. [#2546]
|
|
||||||
|
|
||||||
[#2503]: https://github.com/actix/actix-web/pull/2503
|
[#2503]: https://github.com/actix/actix-web/pull/2503
|
||||||
[#2546]: https://github.com/actix/actix-web/pull/2546
|
[#2546]: https://github.com/actix/actix-web/pull/2546
|
||||||
|
|
|
@ -13,6 +13,7 @@ use actix_http::{
|
||||||
use actix_rt::time::{sleep, Sleep};
|
use actix_rt::time::{sleep, Sleep};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
|
use pin_project_lite::pin_project;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|
||||||
#[cfg(feature = "cookies")]
|
#[cfg(feature = "cookies")]
|
||||||
|
@ -20,12 +21,15 @@ use crate::cookie::{Cookie, ParseError as CookieParseError};
|
||||||
|
|
||||||
use super::{JsonBody, ResponseBody, ResponseTimeout};
|
use super::{JsonBody, ResponseBody, ResponseTimeout};
|
||||||
|
|
||||||
|
pin_project! {
|
||||||
/// Client Response
|
/// Client Response
|
||||||
pub struct ClientResponse<S = BoxedPayloadStream> {
|
pub struct ClientResponse<S = BoxedPayloadStream> {
|
||||||
pub(crate) head: ResponseHead,
|
pub(crate) head: ResponseHead,
|
||||||
|
#[pin]
|
||||||
pub(crate) payload: Payload<S>,
|
pub(crate) payload: Payload<S>,
|
||||||
pub(crate) timeout: ResponseTimeout,
|
pub(crate) timeout: ResponseTimeout,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<S> ClientResponse<S> {
|
impl<S> ClientResponse<S> {
|
||||||
/// Create new Request instance
|
/// Create new Request instance
|
||||||
|
@ -234,10 +238,9 @@ where
|
||||||
type Item = Result<Bytes, PayloadError>;
|
type Item = Result<Bytes, PayloadError>;
|
||||||
|
|
||||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
let this = self.get_mut();
|
let this = self.project();
|
||||||
this.timeout.poll_timeout(cx)?;
|
this.timeout.poll_timeout(cx)?;
|
||||||
|
this.payload.poll_next(cx)
|
||||||
Pin::new(&mut this.payload).poll_next(cx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +249,9 @@ mod tests {
|
||||||
use static_assertions::assert_impl_all;
|
use static_assertions::assert_impl_all;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::any_body::AnyBody;
|
||||||
|
|
||||||
assert_impl_all!(ClientResponse: Unpin);
|
assert_impl_all!(ClientResponse: Unpin);
|
||||||
|
assert_impl_all!(ClientResponse<()>: Unpin);
|
||||||
|
assert_impl_all!(ClientResponse<AnyBody>: Unpin);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue