@@ -37,7 +37,7 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
37
37
/// ```
38
38
pub fn new ( vault_url : & str , token_credential : & ' a T ) -> Result < Self , Error > {
39
39
let vault_url = Url :: parse ( vault_url) . with_context ( ErrorKind :: DataConversion , || {
40
- format ! ( "failed to parse vault url: {}" , vault_url )
40
+ format ! ( "failed to parse vault url: {vault_url}" )
41
41
} ) ?;
42
42
let endpoint = extract_endpoint ( & vault_url) ?;
43
43
let client = KeyClient {
@@ -74,7 +74,7 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
74
74
. await
75
75
. unwrap ( ) ;
76
76
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
77
- format ! ( "failed to read response body text. uri: {}" , uri )
77
+ format ! ( "failed to read response body text. uri: {uri}" )
78
78
} ) ?;
79
79
Ok ( body)
80
80
}
@@ -91,7 +91,7 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
91
91
. await
92
92
. unwrap ( ) ;
93
93
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
94
- format ! ( "failed to read response body text. uri: {}" , uri )
94
+ format ! ( "failed to read response body text. uri: {uri}" )
95
95
} ) ?;
96
96
Ok ( body)
97
97
}
@@ -114,27 +114,24 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
114
114
}
115
115
116
116
let resp = req. send ( ) . await . with_context ( ErrorKind :: Io , || {
117
- format ! ( "failed to send request. uri: {}" , uri )
117
+ format ! ( "failed to send request. uri: {uri}" )
118
118
} ) ?;
119
119
120
120
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
121
- format ! ( "failed to read response body text. uri: {}" , uri )
121
+ format ! ( "failed to read response body text. uri: {uri}" )
122
122
} ) ?;
123
123
let body_deserialized = serde_json:: from_str :: < serde_json:: Value > ( & body) . unwrap ( ) ;
124
124
125
125
if let Some ( err) = body_deserialized. get ( "error" ) {
126
126
let msg = err. get ( "message" ) . ok_or_else ( || {
127
127
Error :: with_message (
128
128
ErrorKind :: DataConversion ,
129
- format ! (
130
- "failed to read message field from error response. body: {}" ,
131
- body
132
- ) ,
129
+ format ! ( "failed to read message field from error response. body: {body}" ) ,
133
130
)
134
131
} ) ?;
135
132
Err ( Error :: with_message (
136
133
ErrorKind :: Other ,
137
- format ! ( "post response error: {}" , msg ) ,
134
+ format ! ( "post response error: {msg}" ) ,
138
135
) )
139
136
} else {
140
137
Ok ( body)
@@ -158,18 +155,15 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
158
155
. unwrap ( ) ;
159
156
160
157
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
161
- format ! ( "failed to read response body text. uri: {}" , uri )
158
+ format ! ( "failed to read response body text. uri: {uri}" )
162
159
} ) ?;
163
160
let body_deserialized = serde_json:: from_str :: < serde_json:: Value > ( & body) . unwrap ( ) ;
164
161
165
162
if let Some ( err) = body_deserialized. get ( "error" ) {
166
163
let msg = err. get ( "message" ) . ok_or_else ( || {
167
164
Error :: with_message (
168
165
ErrorKind :: DataConversion ,
169
- format ! (
170
- "failed to read message field from error response. body: {}" ,
171
- body
172
- ) ,
166
+ format ! ( "failed to read message field from error response. body: {body}" ) ,
173
167
)
174
168
} ) ?;
175
169
Err ( Error :: with_message (
@@ -192,7 +186,7 @@ impl<'a, T: TokenCredential> KeyClient<'a, T> {
192
186
. await
193
187
. unwrap ( ) ;
194
188
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
195
- format ! ( "failed to read response body text. uri: {}" , uri )
189
+ format ! ( "failed to read response body text. uri: {uri}" )
196
190
} ) ?;
197
191
Ok ( body)
198
192
}
@@ -229,7 +223,7 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
229
223
/// ```
230
224
pub fn new ( vault_url : & str , token_credential : & ' a T ) -> Result < Self , Error > {
231
225
let vault_url = Url :: parse ( vault_url) . with_context ( ErrorKind :: DataConversion , || {
232
- format ! ( "failed to parse vault url: {}" , vault_url )
226
+ format ! ( "failed to parse vault url: {vault_url}" )
233
227
} ) ?;
234
228
let endpoint = extract_endpoint ( & vault_url) ?;
235
229
let client = CertificateClient {
@@ -266,7 +260,7 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
266
260
. await
267
261
. unwrap ( ) ;
268
262
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
269
- format ! ( "failed to read response body text. uri: {}" , uri )
263
+ format ! ( "failed to read response body text. uri: {uri}" )
270
264
} ) ?;
271
265
Ok ( body)
272
266
}
@@ -283,7 +277,7 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
283
277
. await
284
278
. unwrap ( ) ;
285
279
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
286
- format ! ( "failed to read response body text. uri: {}" , uri )
280
+ format ! ( "failed to read response body text. uri: {uri}" )
287
281
} ) ?;
288
282
Ok ( body)
289
283
}
@@ -306,11 +300,11 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
306
300
}
307
301
308
302
let resp = req. send ( ) . await . with_context ( ErrorKind :: Io , || {
309
- format ! ( "failed to send request. uri: {}" , uri )
303
+ format ! ( "failed to send request. uri: {uri}" )
310
304
} ) ?;
311
305
312
306
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
313
- format ! ( "failed to read response body text. uri: {}" , uri )
307
+ format ! ( "failed to read response body text. uri: {uri}" )
314
308
} ) ?;
315
309
let body_deserialized = serde_json:: from_str :: < serde_json:: Value > ( & body) . unwrap ( ) ;
316
310
@@ -319,14 +313,13 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
319
313
Error :: with_message (
320
314
ErrorKind :: DataConversion ,
321
315
format ! (
322
- "failed to read message field from error response. uri: {} body: {}" ,
323
- uri, body
316
+ "failed to read message field from error response. uri: {uri} body: {body}"
324
317
) ,
325
318
)
326
319
} ) ?;
327
320
Err ( Error :: with_message (
328
321
ErrorKind :: Other ,
329
- format ! ( "post response error: {}" , msg ) ,
322
+ format ! ( "post response error: {msg}" ) ,
330
323
) )
331
324
} else {
332
325
Ok ( body)
@@ -360,15 +353,12 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
360
353
let msg = err. get ( "message" ) . ok_or_else ( || {
361
354
Error :: with_message (
362
355
ErrorKind :: DataConversion ,
363
- format ! (
364
- "failed to read message field from error response. body: {}" ,
365
- body
366
- ) ,
356
+ format ! ( "failed to read message field from error response. body: {body}" ) ,
367
357
)
368
358
} ) ?;
369
359
Err ( Error :: with_message (
370
360
ErrorKind :: Other ,
371
- format ! ( "post response error. uri: {} msg: {}" , uri , msg ) ,
361
+ format ! ( "post response error. uri: {uri } msg: {msg}" ) ,
372
362
) )
373
363
} else {
374
364
Ok ( body)
@@ -386,7 +376,7 @@ impl<'a, T: TokenCredential> CertificateClient<'a, T> {
386
376
. await
387
377
. unwrap ( ) ;
388
378
let body = resp. text ( ) . await . with_context ( ErrorKind :: Io , || {
389
- format ! ( "failed to read response body text. uri: {}" , uri )
379
+ format ! ( "failed to read response body text. uri: {uri}" )
390
380
} ) ?;
391
381
Ok ( body)
392
382
}
@@ -400,15 +390,15 @@ fn extract_endpoint(url: &Url) -> Result<String, Error> {
400
390
. ok_or_else ( || {
401
391
Error :: with_message (
402
392
ErrorKind :: DataConversion ,
403
- format ! ( "failed to parse host from url. url: {}" , url ) ,
393
+ format ! ( "failed to parse host from url. url: {url}" ) ,
404
394
)
405
395
} ) ?
406
396
. splitn ( 2 , '.' ) // FIXME: replace with split_once() when it is in stable
407
397
. last ( )
408
398
. ok_or_else ( || {
409
399
Error :: with_message (
410
400
ErrorKind :: DataConversion ,
411
- format ! ( "failed to extract endpoint from url. url: {}" , url ) ,
401
+ format ! ( "failed to extract endpoint from url. url: {url}" ) ,
412
402
)
413
403
} ) ?;
414
404
Ok ( format ! ( "{}://{}" , url. scheme( ) , endpoint) )
0 commit comments