diff --git a/Cargo.toml b/Cargo.toml index 9e8a06ac4..b2b9989eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,6 +81,7 @@ url = "2.2" bytes = "1.0" serde = "1.0" serde_urlencoded = "0.7.1" +tower-service = "0.3" # Optional deps... diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index dd2793379..85df20947 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -1515,6 +1515,20 @@ impl fmt::Debug for Client { } } +impl tower_service::Service for Client { + type Response = Response; + type Error = crate::Error; + type Future = Pending; + + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: Request) -> Self::Future { + self.execute_request(req) + } +} + impl fmt::Debug for ClientBuilder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut builder = f.debug_struct("ClientBuilder"); @@ -1665,7 +1679,7 @@ impl ClientRef { } pin_project! { - pub(super) struct Pending { + pub struct Pending { #[pin] inner: PendingInner, }