From 382aada615b03c74ad3d105cf3860354cf35240b Mon Sep 17 00:00:00 2001 From: Daniel Bloom <82895745+Daniel-Bloom-dfinity@users.noreply.github.com> Date: Wed, 14 Jun 2023 04:21:31 -0700 Subject: [PATCH] Replace `ResponseFuture` with `Box` (#28) --- src/lib.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c354865..5d0f426 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,13 +5,14 @@ use std::borrow::Cow; use std::fmt; +use std::future::Future; +use std::pin::Pin; use std::sync::Arc; use base64::prelude::{Engine, BASE64_URL_SAFE_NO_PAD}; use hyper::client::connect::Connect; #[cfg(feature = "hyper-rustls")] use hyper::client::HttpConnector; -use hyper::client::ResponseFuture; use hyper::header::{CONTENT_TYPE, LOCATION}; use hyper::{Body, Method, Request, Response}; use ring::digest::{digest, SHA256}; @@ -599,8 +600,11 @@ struct DefaultClient(hyper::Client>) #[cfg(feature = "hyper-rustls")] impl HttpClient for DefaultClient { - fn request(&self, req: Request) -> ResponseFuture { - self.0.request(req) + fn request( + &self, + req: Request, + ) -> Pin>>>> { + Box::pin(self.0.request(req)) } } @@ -623,15 +627,21 @@ impl Default for DefaultClient { /// A HTTP client based on [`hyper::Client`] pub trait HttpClient: Send + Sync + 'static { /// Send the given request and return the response - fn request(&self, req: Request) -> ResponseFuture; + fn request( + &self, + req: Request, + ) -> Pin>>>>; } impl HttpClient for hyper::Client where C: Connect + Clone + Send + Sync + 'static, { - fn request(&self, req: Request) -> ResponseFuture { - >::request(self, req) + fn request( + &self, + req: Request, + ) -> Pin>>>> { + Box::pin(>::request(self, req)) } }