10
10
//! This code (and its dependencies) are only built if you use the `default_async_client` Cargo
11
11
//! feature.
12
12
13
- use std:: future:: { Future , ready} ;
14
- use std:: str:: FromStr ;
15
- use std:: sync:: Arc ;
16
- use bytes:: Bytes ;
17
- use futures:: { FutureExt , TryFutureExt , TryStreamExt } ;
18
- use crate :: async_client_trait:: { AppAuthClient , HttpClient , HttpRequest , HttpRequestResultRaw ,
19
- NoauthClient , TeamAuthClient , TeamSelect , UserAuthClient } ;
13
+ use crate :: async_client_trait:: {
14
+ AppAuthClient , HttpClient , HttpRequest , HttpRequestResultRaw , NoauthClient , TeamAuthClient ,
15
+ TeamSelect , UserAuthClient ,
16
+ } ;
20
17
use crate :: default_client_common:: impl_set_path_root;
21
- use crate :: Error ;
22
18
use crate :: oauth2:: { Authorization , TokenCache } ;
19
+ use crate :: Error ;
20
+ use bytes:: Bytes ;
21
+ use futures:: { FutureExt , TryFutureExt , TryStreamExt } ;
22
+ use std:: future:: { ready, Future } ;
23
+ use std:: str:: FromStr ;
24
+ use std:: sync:: Arc ;
23
25
24
26
macro_rules! impl_update_token {
25
27
( $self: ident) => {
@@ -76,7 +78,7 @@ impl HttpClient for UserAuthDefaultClient {
76
78
& self ,
77
79
request : Self :: Request ,
78
80
body : Bytes ,
79
- ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
81
+ ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
80
82
self . inner . execute ( request, body)
81
83
}
82
84
@@ -131,7 +133,7 @@ impl HttpClient for TeamAuthDefaultClient {
131
133
& self ,
132
134
request : Self :: Request ,
133
135
body : Bytes ,
134
- ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
136
+ ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
135
137
self . inner . execute ( request, body)
136
138
}
137
139
@@ -182,12 +184,17 @@ impl AppAuthDefaultClient {
182
184
impl HttpClient for AppAuthDefaultClient {
183
185
type Request = ReqwestRequest ;
184
186
185
- fn execute ( & self , request : Self :: Request , body : Bytes ) -> impl Future < Output =Result < HttpRequestResultRaw , Error > > + Send {
187
+ fn execute (
188
+ & self ,
189
+ request : Self :: Request ,
190
+ body : Bytes ,
191
+ ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
186
192
self . inner . execute ( request, body)
187
193
}
188
194
189
195
fn new_request ( & self , url : & str ) -> Self :: Request {
190
- self . inner . new_request ( url)
196
+ self . inner
197
+ . new_request ( url)
191
198
. set_header ( "Authorization" , & self . auth )
192
199
}
193
200
}
@@ -212,7 +219,7 @@ impl HttpClient for NoauthDefaultClient {
212
219
& self ,
213
220
request : Self :: Request ,
214
221
body : Bytes ,
215
- ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
222
+ ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
216
223
self . inner . execute ( request, body)
217
224
}
218
225
@@ -240,7 +247,7 @@ impl HttpClient for TokenUpdateClient<'_> {
240
247
& self ,
241
248
request : Self :: Request ,
242
249
body : Bytes ,
243
- ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
250
+ ) -> impl Future < Output = Result < HttpRequestResultRaw , Error > > + Send {
244
251
self . inner . execute ( request, body)
245
252
}
246
253
@@ -263,7 +270,7 @@ impl Default for ReqwestClient {
263
270
. https_only ( true )
264
271
. http2_prior_knowledge ( )
265
272
. build ( )
266
- . unwrap ( )
273
+ . unwrap ( ) ,
267
274
}
268
275
}
269
276
}
@@ -290,7 +297,8 @@ impl HttpClient for ReqwestClient {
290
297
if !body. is_empty ( ) {
291
298
* req. body_mut ( ) = Some ( reqwest:: Body :: from ( body) ) ;
292
299
}
293
- self . inner . execute ( req)
300
+ self . inner
301
+ . execute ( req)
294
302
. map_ok_or_else (
295
303
|e| Err ( Error :: HttpClient ( Box :: new ( e) ) ) ,
296
304
|resp| {
@@ -317,7 +325,8 @@ impl HttpClient for ReqwestClient {
317
325
} )
318
326
. transpose ( ) ?;
319
327
320
- let body = resp. bytes_stream ( )
328
+ let body = resp
329
+ . bytes_stream ( )
321
330
. map_err ( |e| futures:: io:: Error :: new ( futures:: io:: ErrorKind :: Other , e) )
322
331
. into_async_read ( ) ;
323
332
@@ -327,7 +336,7 @@ impl HttpClient for ReqwestClient {
327
336
content_length,
328
337
body : Box :: new ( body) ,
329
338
} )
330
- }
339
+ } ,
331
340
)
332
341
. boxed ( )
333
342
}
0 commit comments