Skip to content

Commit

Permalink
feat(client): impl tower_service::Service for &Client (hyperium#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
tesaguri authored and Benxiang Ge committed Jul 26, 2021
1 parent bb15790 commit 83a72ae
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,26 @@ where
}
}

impl<C, B> tower_service::Service<Request<B>> for &'_ Client<C, B>
where
C: Connect + Clone + Send + Sync + 'static,
B: HttpBody + Send + 'static,
B::Data: Send,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
{
type Response = Response<Body>;
type Error = crate::Error;
type Future = ResponseFuture;

fn poll_ready(&mut self, _: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}

fn call(&mut self, req: Request<B>) -> Self::Future {
self.request(req)
}
}

impl<C: Clone, B> Clone for Client<C, B> {
fn clone(&self) -> Client<C, B> {
Client {
Expand Down

0 comments on commit 83a72ae

Please sign in to comment.