Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tower Service for Client #1420

Merged
merged 2 commits into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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