-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Document how to close a stream correctly #1493
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks great! I'll give @Ralith a chance to review as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Good call on actually compiling the example, there were quite a few errors! I've left some EOF wording in there since I think that is the terminology when using stream I think. Let me know if you'd still like to remove this. |
Please take another look, I've adopted the suggested wording changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
It is not trivial to correctly close a stream without errors and knowing everything is fully acknowledged. Describe some details around this.
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
quinn/src/recv_stream.rs
Outdated
/// let mut buf = [0u8; 10]; | ||
/// let data = recv_stream.read_exact(&mut buf).await?; | ||
/// if recv_stream.read_to_end(0).await.is_err() { | ||
/// recv_stream.stop(0u8.into()).ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, of course this call is impossible because read_to_end
takes ownership. Perhaps we should change it to take &mut self
...
Apologies for just using the github suggestions and letting CI find the bugs, which is just painful and slow. I've fixed up the example locally and it all works again. I stuck with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for seeing this through!
It is not trivial to correctly close a stream without errors and knowing everything is fully acknowledged. Describe some details around this.