-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock::with_chunked_body could use better documentation #190
Comments
That is correct and, as you pointed out, you can sleep between writes to simulate delay between the chunks. I'll make a note to update the docs but PRs are also welcome 😉 |
Addressed in #191 |
Thank you! One question still remains: Should it be |
Aside from semantics do you see any other benefits in using |
It would allow users to consume values in the callback that get moved in from outside the callback. For example, you might have a It's also not a problem I have myself. I agree that it's probably not worth doing a breaking change just for this, but maybe something to look at when making other breaking changes. |
Reading the documentation for
with_chunked_body
I wasn't immediately sure how the callback function is used. Is it called once per chunk? Or just once? What determines the size of the chunks?I think the answers are: It's called just once. Every call to
write*
on the writer argument becomes one chunk. The callback function can sleep between the write calls in order to put delays between the chunks. The callback function can also return an error after any number of write calls in order to abort the response.Should the type of the callback function be
FnOnce
rather thanFn
to emphasize the fact that it's only called once?The text was updated successfully, but these errors were encountered: