Implement tower Service for Client (#1420)

* Add tower-service

* Implement tower Service for Client
This commit is contained in:
Mathspy
2022-04-20 19:14:35 -04:00
committed by GitHub
parent 5d8bf830cb
commit d24a5286c7
2 changed files with 16 additions and 1 deletions

View File

@@ -81,6 +81,7 @@ url = "2.2"
bytes = "1.0"
serde = "1.0"
serde_urlencoded = "0.7.1"
tower-service = "0.3"
# Optional deps...

View File

@@ -1515,6 +1515,20 @@ impl fmt::Debug 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");
@@ -1665,7 +1679,7 @@ impl ClientRef {
}
pin_project! {
pub(super) struct Pending {
pub struct Pending {
#[pin]
inner: PendingInner,
}