Skip to content

Commit

Permalink
Implement tower Service for Client (#1420)
Browse files Browse the repository at this point in the history
* Add tower-service

* Implement tower Service for Client
  • Loading branch information
Mathspy committed Apr 20, 2022
1 parent 5d8bf83 commit d24a528
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -81,6 +81,7 @@ url = "2.2"
bytes = "1.0"
serde = "1.0"
serde_urlencoded = "0.7.1"
tower-service = "0.3"

# Optional deps...

Expand Down
16 changes: 15 additions & 1 deletion src/async_impl/client.rs
Expand Up @@ -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");
Expand Down Expand Up @@ -1665,7 +1679,7 @@ impl ClientRef {
}

pin_project! {
pub(super) struct Pending {
pub struct Pending {
#[pin]
inner: PendingInner,
}
Expand Down

0 comments on commit d24a528

Please sign in to comment.