feat: enable client to be a service without ownership (#1556)

This commit is contained in:
Marcus Griep
2022-06-13 16:45:30 -04:00
committed by GitHub
parent c4603b0a5d
commit 7a11d397eb

View File

@@ -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 { impl fmt::Debug for ClientBuilder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut builder = f.debug_struct("ClientBuilder"); let mut builder = f.debug_struct("ClientBuilder");