Skip to content

Commit 77c3b5b

Browse files
authored
feat(client): impl tower_service::Service for &Client (#2089)
1 parent 07f2fd1 commit 77c3b5b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/client/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,26 @@ where
562562
}
563563
}
564564

565+
impl<C, B> tower_service::Service<Request<B>> for &'_ Client<C, B>
566+
where
567+
C: Connect + Clone + Send + Sync + 'static,
568+
B: HttpBody + Send + 'static,
569+
B::Data: Send,
570+
B::Error: Into<Box<dyn StdError + Send + Sync>>,
571+
{
572+
type Response = Response<Body>;
573+
type Error = crate::Error;
574+
type Future = ResponseFuture;
575+
576+
fn poll_ready(&mut self, _: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>> {
577+
Poll::Ready(Ok(()))
578+
}
579+
580+
fn call(&mut self, req: Request<B>) -> Self::Future {
581+
self.request(req)
582+
}
583+
}
584+
565585
impl<C: Clone, B> Clone for Client<C, B> {
566586
fn clone(&self) -> Client<C, B> {
567587
Client {

0 commit comments

Comments
 (0)