Skip to content

Commit

Permalink
feat: enable client to be a service without ownership (#1556)
Browse files Browse the repository at this point in the history
  • Loading branch information
neoeinstein authored Jun 13, 2022
1 parent c4603b0 commit 7a11d39
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,20 @@ impl tower_service::Service<Request> for Client {
}
}

impl tower_service::Service<Request> for &'_ Client {
type Response = Response;
type Error = crate::Error;
type Future = Pending;

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
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");
Expand Down

0 comments on commit 7a11d39

Please sign in to comment.