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 `JsonBody` 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
|
||||
[#2546]: https://github.com/actix/actix-web/pull/2546
|
||||
|
|
|
@ -13,6 +13,7 @@ use actix_http::{
|
|||
use actix_rt::time::{sleep, Sleep};
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use pin_project_lite::pin_project;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
#[cfg(feature = "cookies")]
|
||||
|
@ -20,11 +21,14 @@ use crate::cookie::{Cookie, ParseError as CookieParseError};
|
|||
|
||||
use super::{JsonBody, ResponseBody, ResponseTimeout};
|
||||
|
||||
/// Client Response
|
||||
pub struct ClientResponse<S = BoxedPayloadStream> {
|
||||
pin_project! {
|
||||
/// Client Response
|
||||
pub struct ClientResponse<S = BoxedPayloadStream> {
|
||||
pub(crate) head: ResponseHead,
|
||||
#[pin]
|
||||
pub(crate) payload: Payload<S>,
|
||||
pub(crate) timeout: ResponseTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> ClientResponse<S> {
|
||||
|
@ -234,10 +238,9 @@ where
|
|||
type Item = Result<Bytes, PayloadError>;
|
||||
|
||||
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)?;
|
||||
|
||||
Pin::new(&mut this.payload).poll_next(cx)
|
||||
this.payload.poll_next(cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,6 +249,9 @@ mod tests {
|
|||
use static_assertions::assert_impl_all;
|
||||
|
||||
use super::*;
|
||||
use crate::any_body::AnyBody;
|
||||
|
||||
assert_impl_all!(ClientResponse: Unpin);
|
||||
assert_impl_all!(ClientResponse<()>: Unpin);
|
||||
assert_impl_all!(ClientResponse<AnyBody>: Unpin);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue