Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBody constructor doc examples #139
Conversation
seanmonstar
reviewed
Jun 6, 2017
|
Thanks for the pull request! Just one thought about the text of the |
src/body.rs
Outdated
| /// # use reqwest::Body; | ||
| /// # fn run() -> Result<(), Box<std::error::Error>> { | ||
| /// // &[u8] implements std::io::Read, and the source `s` has a | ||
| /// // 'static lifetime and a known number of bytes. |
This comment has been minimized.
This comment has been minimized.
seanmonstar
Jun 6, 2017
Owner
I think the example probably should address the point in the lines above, about how this constructor is useful if "we don't want to load the data in memory". If someone has a a bundle of bytes, it's actually better in to use Body::from().
This was originally added to allow someone to include the length with a File or similar.
let file = File::open("foo.txt")?;
let len = file.metadata()?.len();
let body = Body::sized(file, len);
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
seanmonstar
merged commit 006368f
into
seanmonstar:master
Jun 6, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks! |
jaemk
deleted the
jaemk:docs
branch
Jun 7, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
jaemk commentedJun 6, 2017
•
edited
Addresses libz blitz (#120) "Examples for the Body constructors", issue #116