@@ -156,7 +156,7 @@ impl Request {
156
156
/// ```
157
157
/// # fn main() -> Result<(), http_types::Error> {
158
158
/// #
159
- /// use http_types::{Url, Method, Request, Response, StatusCode};
159
+ /// use http_types::{Method, Request, Response, StatusCode, Url };
160
160
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
161
161
/// assert_eq!(req.url().scheme(), "https");
162
162
/// #
@@ -173,7 +173,7 @@ impl Request {
173
173
/// ```
174
174
/// # fn main() -> Result<(), http_types::Error> {
175
175
/// #
176
- /// use http_types::{Url, Method, Request, Response, StatusCode};
176
+ /// use http_types::{Method, Request, Response, StatusCode, Url };
177
177
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
178
178
/// req.url_mut().set_scheme("http");
179
179
/// assert_eq!(req.url().scheme(), "http");
@@ -189,7 +189,7 @@ impl Request {
189
189
/// # Examples
190
190
///
191
191
/// ```
192
- /// use http_types::{Url, Method, Request};
192
+ /// use http_types::{Method, Request, Url };
193
193
///
194
194
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
195
195
/// req.set_body("Hello, Nori!");
@@ -208,7 +208,7 @@ impl Request {
208
208
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
209
209
/// # async_std::task::block_on(async {
210
210
/// #
211
- /// use http_types::{Body, Url, Method, Request};
211
+ /// use http_types::{Body, Method, Request, Url };
212
212
///
213
213
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
214
214
/// req.set_body("Hello, Nori!");
@@ -235,7 +235,7 @@ impl Request {
235
235
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
236
236
/// # async_std::task::block_on(async {
237
237
/// #
238
- /// use http_types::{Body, Url, Method, Request};
238
+ /// use http_types::{Body, Method, Request, Url };
239
239
///
240
240
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
241
241
/// req.set_body("Hello, Nori!");
@@ -262,7 +262,7 @@ impl Request {
262
262
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
263
263
/// # async_std::task::block_on(async {
264
264
/// #
265
- /// use http_types::{Body, Url, Method, Request};
265
+ /// use http_types::{Body, Method, Request, Url };
266
266
///
267
267
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
268
268
/// req.set_body("Hello, Nori!");
@@ -295,8 +295,8 @@ impl Request {
295
295
/// # use std::io::prelude::*;
296
296
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
297
297
/// # async_std::task::block_on(async {
298
- /// use http_types::{Body, Url, Method, Request};
299
298
/// use async_std::io::Cursor;
299
+ /// use http_types::{Body, Method, Request, Url};
300
300
///
301
301
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
302
302
///
@@ -322,7 +322,7 @@ impl Request {
322
322
///
323
323
/// ```
324
324
/// # fn main() -> Result<(), http_types::Error> { async_std::task::block_on(async {
325
- /// use http_types::{Body, Url, Method, Request};
325
+ /// use http_types::{Body, Method, Request, Url };
326
326
///
327
327
/// let bytes = vec![1, 2, 3];
328
328
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
@@ -348,13 +348,17 @@ impl Request {
348
348
///
349
349
/// ```
350
350
/// # fn main() -> Result<(), http_types::Error> { async_std::task::block_on(async {
351
- /// use http_types::{Body, Url, Method, Request };
352
- /// use http_types::convert::{Serialize, Deserialize };
351
+ /// use http_types::convert::{Deserialize, Serialize };
352
+ /// use http_types::{Body, Method, Request, Url };
353
353
///
354
354
/// #[derive(Debug, Serialize, Deserialize)]
355
- /// struct Cat { name: String }
355
+ /// struct Cat {
356
+ /// name: String,
357
+ /// }
356
358
///
357
- /// let cat = Cat { name: String::from("chashu") };
359
+ /// let cat = Cat {
360
+ /// name: String::from("chashu"),
361
+ /// };
358
362
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
359
363
/// req.set_body(Body::from_json(&cat)?);
360
364
///
@@ -378,13 +382,17 @@ impl Request {
378
382
///
379
383
/// ```
380
384
/// # fn main() -> Result<(), http_types::Error> { async_std::task::block_on(async {
381
- /// use http_types::{Body, Url, Method, Request };
382
- /// use http_types::convert::{Serialize, Deserialize };
385
+ /// use http_types::convert::{Deserialize, Serialize };
386
+ /// use http_types::{Body, Method, Request, Url };
383
387
///
384
388
/// #[derive(Debug, Serialize, Deserialize)]
385
- /// struct Cat { name: String }
389
+ /// struct Cat {
390
+ /// name: String,
391
+ /// }
386
392
///
387
- /// let cat = Cat { name: String::from("chashu") };
393
+ /// let cat = Cat {
394
+ /// name: String::from("chashu"),
395
+ /// };
388
396
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com").unwrap());
389
397
/// req.set_body(Body::from_form(&cat)?);
390
398
///
@@ -419,7 +427,7 @@ impl Request {
419
427
/// ```
420
428
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
421
429
/// #
422
- /// use http_types::{Url, Method, Request};
430
+ /// use http_types::{Method, Request, Url };
423
431
///
424
432
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
425
433
/// req.insert_header("Content-Type", "text/plain");
@@ -436,15 +444,16 @@ impl Request {
436
444
437
445
/// Append a header to the headers.
438
446
///
439
- /// Unlike `insert` this function will not override the contents of a header, but insert a
440
- /// header if there aren't any. Or else append to the existing list of headers.
447
+ /// Unlike `insert` this function will not override the contents of a
448
+ /// header, but insert a header if there aren't any. Or else append to
449
+ /// the existing list of headers.
441
450
///
442
451
/// # Examples
443
452
///
444
453
/// ```
445
454
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
446
455
/// #
447
- /// use http_types::{Url, Method, Request};
456
+ /// use http_types::{Method, Request, Url };
448
457
///
449
458
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
450
459
/// req.append_header("Content-Type", "text/plain");
@@ -478,14 +487,16 @@ impl Request {
478
487
479
488
/// Get the length of the body stream, if it has been set.
480
489
///
481
- /// This value is set when passing a fixed-size object into as the body. E.g. a string, or a
482
- /// buffer. Consumers of this API should check this value to decide whether to use `Chunked`
483
- /// encoding, or set the response length.
490
+ /// This value is set when passing a fixed-size object into as the body.
491
+ /// E.g. a string, or a buffer. Consumers of this API should check this
492
+ /// value to decide whether to use `Chunked` encoding, or set the
493
+ /// response length.
484
494
pub fn len ( & self ) -> Option < usize > {
485
495
self . body . len ( )
486
496
}
487
497
488
- /// Returns `true` if the request has a set body stream length of zero, `false` otherwise.
498
+ /// Returns `true` if the request has a set body stream length of zero,
499
+ /// `false` otherwise.
489
500
pub fn is_empty ( & self ) -> Option < bool > {
490
501
self . body . is_empty ( )
491
502
}
@@ -495,7 +506,7 @@ impl Request {
495
506
/// # Examples
496
507
///
497
508
/// ```
498
- /// use http_types::{Url, Method, Request, Version};
509
+ /// use http_types::{Method, Request, Url , Version};
499
510
///
500
511
/// # fn main() -> Result<(), http_types::Error> {
501
512
/// #
@@ -516,7 +527,7 @@ impl Request {
516
527
/// # Examples
517
528
///
518
529
/// ```
519
- /// use http_types::{Url, Method, Request, Version};
530
+ /// use http_types::{Method, Request, Url , Version};
520
531
///
521
532
/// # fn main() -> Result<(), http_types::Error> {
522
533
/// #
@@ -552,8 +563,8 @@ impl Request {
552
563
self . headers . iter ( )
553
564
}
554
565
555
- /// An iterator visiting all header pairs in arbitrary order, with mutable references to the
556
- /// values.
566
+ /// An iterator visiting all header pairs in arbitrary order, with mutable
567
+ /// references to the values.
557
568
pub fn iter_mut ( & mut self ) -> headers:: IterMut < ' _ > {
558
569
self . headers . iter_mut ( )
559
570
}
@@ -580,7 +591,7 @@ impl Request {
580
591
/// ```
581
592
/// # fn main() -> Result<(), http_types::Error> {
582
593
/// #
583
- /// use http_types::{Url, Method, Request, Version};
594
+ /// use http_types::{Method, Request, Url , Version};
584
595
///
585
596
/// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
586
597
/// req.ext_mut().insert("hello from the extension");
@@ -599,15 +610,18 @@ impl Request {
599
610
/// ```no_run
600
611
/// # #[async_std::main]
601
612
/// # async fn main() -> http_types::Result<()> {
602
- /// use http_types::{Url, Method, Request };
603
- /// use http_types::convert::{Serialize, Deserialize };
613
+ /// use http_types::convert::{Deserialize, Serialize };
614
+ /// use http_types::{Method, Request, Url };
604
615
///
605
616
/// #[derive(Serialize, Deserialize)]
606
617
/// struct Index {
607
- /// page: u32
618
+ /// page: u32,
608
619
/// }
609
620
///
610
- /// let req = Request::new(Method::Get, Url::parse("https://httpbin.org/get?page=2").unwrap());
621
+ /// let req = Request::new(
622
+ /// Method::Get,
623
+ /// Url::parse("https://httpbin.org/get?page=2").unwrap(),
624
+ /// );
611
625
/// let Index { page } = req.query()?;
612
626
/// assert_eq!(page, 2);
613
627
/// # Ok(()) }
@@ -628,16 +642,19 @@ impl Request {
628
642
/// ```no_run
629
643
/// # #[async_std::main]
630
644
/// # async fn main() -> http_types::Result<()> {
631
- /// use http_types::{Url, Method, Request };
632
- /// use http_types::convert::{Serialize, Deserialize };
645
+ /// use http_types::convert::{Deserialize, Serialize };
646
+ /// use http_types::{Method, Request, Url };
633
647
///
634
648
/// #[derive(Serialize, Deserialize)]
635
649
/// struct Index {
636
- /// page: u32
650
+ /// page: u32,
637
651
/// }
638
652
///
639
653
/// let query = Index { page: 2 };
640
- /// let mut req = Request::new(Method::Get, Url::parse("https://httpbin.org/get?page=2").unwrap());
654
+ /// let mut req = Request::new(
655
+ /// Method::Get,
656
+ /// Url::parse("https://httpbin.org/get?page=2").unwrap(),
657
+ /// );
641
658
/// req.set_query(&query)?;
642
659
/// assert_eq!(req.url().query(), Some("page=2"));
643
660
/// assert_eq!(req.url().as_str(), "https://httpbin.org/get?page=2");
0 commit comments