feat(client): impl tower_service::Service for &Client (#2089)

This commit is contained in:
Daiki Mizukami
2020-06-26 00:18:05 +09:00
committed by GitHub
parent 07f2fd1775
commit 77c3b5bc0c

View File

@@ -562,6 +562,26 @@ where
} }
} }
impl<C, B> tower_service::Service<Request<B>> for &'_ Client<C, B>
where
C: Connect + Clone + Send + Sync + 'static,
B: HttpBody + Send + 'static,
B::Data: Send,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
{
type Response = Response<Body>;
type Error = crate::Error;
type Future = ResponseFuture;
fn poll_ready(&mut self, _: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: Request<B>) -> Self::Future {
self.request(req)
}
}
impl<C: Clone, B> Clone for Client<C, B> { impl<C: Clone, B> Clone for Client<C, B> {
fn clone(&self) -> Client<C, B> { fn clone(&self) -> Client<C, B> {
Client { Client {