From 04c74ef596eb313b785ecad6c42c0375ddbb1e96 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 4 May 2018 15:21:59 -0700 Subject: [PATCH] feat(client): rename `FutureResponse` to `ResponseFuture` BREAKING CHANGE: Replace any references of `hyper::client::FutureResponse` to `hyper::client::ResponseFuture`. --- src/client/mod.rs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index eb03afc754..8f8ee03bf5 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -172,7 +172,7 @@ where C: Connect + Sync + 'static, /// This requires that the `Payload` type have a `Default` implementation. /// It *should* return an "empty" version of itself, such that /// `Payload::is_end_stream` is `true`. - pub fn get(&self, uri: Uri) -> FutureResponse + pub fn get(&self, uri: Uri) -> ResponseFuture where B: Default, { @@ -187,20 +187,20 @@ where C: Connect + Sync + 'static, } /// Send a constructed Request using this Client. - pub fn request(&self, mut req: Request) -> FutureResponse { + pub fn request(&self, mut req: Request) -> ResponseFuture { match req.version() { Version::HTTP_10 | Version::HTTP_11 => (), other => { error!("Request has unsupported version \"{:?}\"", other); //TODO: replace this with a proper variant - return FutureResponse(Box::new(future::err(::Error::new_user_unsupported_version()))); + return ResponseFuture::new(Box::new(future::err(::Error::new_user_unsupported_version()))); } } if req.method() == &Method::CONNECT { debug!("Client does not support CONNECT requests"); - return FutureResponse(Box::new(future::err(::Error::new_user_unsupported_request_method()))); + return ResponseFuture::new(Box::new(future::err(::Error::new_user_unsupported_request_method()))); } let uri = req.uri().clone(); @@ -210,7 +210,7 @@ where C: Connect + Sync + 'static, } _ => { //TODO: replace this with a proper variant - return FutureResponse(Box::new(future::err(::Error::new_io( + return ResponseFuture::new(Box::new(future::err(::Error::new_io( io::Error::new( io::ErrorKind::InvalidInput, "invalid URI for Client Request" @@ -241,7 +241,7 @@ where C: Connect + Sync + 'static, domain: domain, uri: uri, }; - FutureResponse(Box::new(fut)) + ResponseFuture::new(Box::new(fut)) } //TODO: replace with `impl Future` when stable @@ -429,20 +429,30 @@ impl fmt::Debug for Client { /// A `Future` that will resolve to an HTTP Response. #[must_use = "futures do nothing unless polled"] -pub struct FutureResponse(Box, Error=::Error> + Send + 'static>); +pub struct ResponseFuture { + inner: Box, Error=::Error> + Send>, +} + +impl ResponseFuture { + fn new(fut: Box, Error=::Error> + Send>) -> Self { + Self { + inner: fut, + } + } +} -impl fmt::Debug for FutureResponse { +impl fmt::Debug for ResponseFuture { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Future") } } -impl Future for FutureResponse { +impl Future for ResponseFuture { type Item = Response; type Error = ::Error; fn poll(&mut self) -> Poll { - self.0.poll() + self.inner.poll() } } @@ -704,7 +714,7 @@ impl Builder { /// connection, and then encounters an error immediately as the idle /// connection was found to be unusable. /// - /// When this is set to `false`, the related `FutureResponse` would instead + /// When this is set to `false`, the related `ResponseFuture` would instead /// resolve to an `Error::Cancel`. /// /// Default is `true`.