@@ -2161,6 +2161,62 @@ impl tower_service::Service<Request> for &'_ Client {
2161
2161
}
2162
2162
}
2163
2163
2164
+ impl tower_service:: Service < http:: Request < crate :: Body > > for Client {
2165
+ type Response = http:: Response < crate :: Body > ;
2166
+ type Error = crate :: Error ;
2167
+ type Future = MappedPending ;
2168
+
2169
+ fn poll_ready ( & mut self , _cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
2170
+ Poll :: Ready ( Ok ( ( ) ) )
2171
+ }
2172
+
2173
+ fn call ( & mut self , req : http:: Request < crate :: Body > ) -> Self :: Future {
2174
+ match req. try_into ( ) {
2175
+ Ok ( req) => MappedPending :: new ( self . execute_request ( req) ) ,
2176
+ Err ( err) => MappedPending :: new ( Pending :: new_err ( err) ) ,
2177
+ }
2178
+ }
2179
+ }
2180
+
2181
+ impl tower_service:: Service < http:: Request < crate :: Body > > for & ' _ Client {
2182
+ type Response = http:: Response < crate :: Body > ;
2183
+ type Error = crate :: Error ;
2184
+ type Future = MappedPending ;
2185
+
2186
+ fn poll_ready ( & mut self , _cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
2187
+ Poll :: Ready ( Ok ( ( ) ) )
2188
+ }
2189
+
2190
+ fn call ( & mut self , req : http:: Request < crate :: Body > ) -> Self :: Future {
2191
+ match req. try_into ( ) {
2192
+ Ok ( req) => MappedPending :: new ( self . execute_request ( req) ) ,
2193
+ Err ( err) => MappedPending :: new ( Pending :: new_err ( err) ) ,
2194
+ }
2195
+ }
2196
+ }
2197
+
2198
+ pin_project ! {
2199
+ pub struct MappedPending {
2200
+ #[ pin]
2201
+ inner: Pending ,
2202
+ }
2203
+ }
2204
+
2205
+ impl MappedPending {
2206
+ fn new ( inner : Pending ) -> MappedPending {
2207
+ Self { inner }
2208
+ }
2209
+ }
2210
+
2211
+ impl Future for MappedPending {
2212
+ type Output = Result < http:: Response < crate :: Body > , crate :: Error > ;
2213
+
2214
+ fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
2215
+ let inner = self . project ( ) . inner ;
2216
+ inner. poll ( cx) . map_ok ( Into :: into)
2217
+ }
2218
+ }
2219
+
2164
2220
impl fmt:: Debug for ClientBuilder {
2165
2221
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
2166
2222
let mut builder = f. debug_struct ( "ClientBuilder" ) ;
0 commit comments