improve docs around Body type
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/body.rs
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/body.rs
									
									
									
									
									
								
							| @@ -7,7 +7,13 @@ use hyper::{self, Chunk}; | |||||||
|  |  | ||||||
| use {async_impl, wait}; | use {async_impl, wait}; | ||||||
|  |  | ||||||
| /// Body type for a request. | /// The body of a `Request`. | ||||||
|  | /// | ||||||
|  | /// In most cases, this is not needed directly, as the | ||||||
|  | /// [`RequestBuilder.body`][builder] method uses `Into<Body>`, which allows | ||||||
|  | /// passing many things (like a string or vector of bytes). | ||||||
|  | /// | ||||||
|  | /// [builder]: ./struct.RequestBuilder.html#method.body | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| pub struct Body { | pub struct Body { | ||||||
|     reader: Kind, |     reader: Kind, | ||||||
| @@ -52,10 +58,9 @@ impl Body { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Create a `Body` from a `Reader` where we can predict the size in |     /// Create a `Body` from a `Read` where the size is known in advance | ||||||
|     /// advance, but where we don't want to load the data in memory.  This |     /// advance, but the data should not be loaded in full to memory. This will | ||||||
|     /// is useful if we need to ensure `Content-Length` is passed with the |     /// set the `Content-Length` header, and stream from the `Read`. | ||||||
|     /// request. |  | ||||||
|     /// |     /// | ||||||
|     /// ```rust |     /// ```rust | ||||||
|     /// # use std::fs::File; |     /// # use std::fs::File; | ||||||
|   | |||||||
| @@ -156,6 +156,10 @@ impl RequestBuilder { | |||||||
|  |  | ||||||
|     /// Set the request body. |     /// Set the request body. | ||||||
|     /// |     /// | ||||||
|  |     /// # Examples | ||||||
|  |     /// | ||||||
|  |     /// Using a string: | ||||||
|  |     /// | ||||||
|     /// ```rust |     /// ```rust | ||||||
|     /// # fn run() -> Result<(), Box<::std::error::Error>> { |     /// # fn run() -> Result<(), Box<::std::error::Error>> { | ||||||
|     /// let client = reqwest::Client::new()?; |     /// let client = reqwest::Client::new()?; | ||||||
| @@ -166,6 +170,8 @@ impl RequestBuilder { | |||||||
|     /// # } |     /// # } | ||||||
|     /// ``` |     /// ``` | ||||||
|     /// |     /// | ||||||
|  |     /// Using a `File`: | ||||||
|  |     /// | ||||||
|     /// ```rust |     /// ```rust | ||||||
|     /// # use std::fs; |     /// # use std::fs; | ||||||
|     /// # fn run() -> Result<(), Box<::std::error::Error>> { |     /// # fn run() -> Result<(), Box<::std::error::Error>> { | ||||||
| @@ -178,6 +184,8 @@ impl RequestBuilder { | |||||||
|     /// # } |     /// # } | ||||||
|     /// ``` |     /// ``` | ||||||
|     /// |     /// | ||||||
|  |     /// Using arbitrary bytes: | ||||||
|  |     /// | ||||||
|     /// ```rust |     /// ```rust | ||||||
|     /// # use std::fs; |     /// # use std::fs; | ||||||
|     /// # fn run() -> Result<(), Box<::std::error::Error>> { |     /// # fn run() -> Result<(), Box<::std::error::Error>> { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user