Implement tower Service for Client (#1420)
* Add tower-service * Implement tower Service for Client
This commit is contained in:
@@ -81,6 +81,7 @@ url = "2.2"
|
|||||||
bytes = "1.0"
|
bytes = "1.0"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_urlencoded = "0.7.1"
|
serde_urlencoded = "0.7.1"
|
||||||
|
tower-service = "0.3"
|
||||||
|
|
||||||
# Optional deps...
|
# Optional deps...
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
impl fmt::Debug for ClientBuilder {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut builder = f.debug_struct("ClientBuilder");
|
let mut builder = f.debug_struct("ClientBuilder");
|
||||||
@@ -1665,7 +1679,7 @@ impl ClientRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
pub(super) struct Pending {
|
pub struct Pending {
|
||||||
#[pin]
|
#[pin]
|
||||||
inner: PendingInner,
|
inner: PendingInner,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user