From edbd10ac96c5cc6dbeca80ada80f143dbd13d118 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Wed, 4 Dec 2019 20:07:16 -0500 Subject: [PATCH] feat(client): impl tower_service::Service for Client --- src/client/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/client/mod.rs b/src/client/mod.rs index afb7aba9d1..1054ec2882 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -528,6 +528,26 @@ where C: Connect + Clone + Send + Sync + 'static, } } +impl tower_service::Service> for Client +where C: Connect + Clone + Send + Sync + 'static, + C::Transport: Unpin + Send + 'static, + C::Future: Unpin + Send + 'static, + B: Payload + Unpin + Send + 'static, + B::Data: Send + Unpin, +{ + type Response = Response; + type Error = crate::Error; + type Future = ResponseFuture; + + fn poll_ready(&mut self, _: &mut task::Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: Request) -> Self::Future { + self.request(req) + } +} + impl Clone for Client { fn clone(&self) -> Client { Client {