-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Change the UnixStream interface so that close_write on a variable preven... #19251
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
Conversation
…vents (at compile time) future attempts to write to that variable. This is also true for close_read. Note that UnixStreams cloned from a variable on which close_* is called are not affected by this change. They have the same interface as before, in which reads and writes may fail due to the underlying stream being closed for that operation.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. |
This is an interesting idea, thanks for the PR! I have a few concerns with this approach, however:
|
Q: Why not A: I wanted to see if this approach works well first, in no small part based on feedback on this PR. Q: Can't you seesaw back and forth, getting back your read abilities by calling A: I don't think so. Calling Q: Should we hold off due to timeout issues? A: I suspect this change and any timeout changes would interact in a commutative and rather mechanical way, not requiring much thought. |
Ah I see how it work! I got lost in the trait impls, clever though! This does have the unfortunate drawback that the API of It may be best to punt this sort of static guarantee to an application writer rather than the standard library itself. I personally expect the |
The duplication is unfortunate, thought relatively small, since the As far as the problems with storing these in a structure goes, this is roughly the same thing one gets from the
|
Many methods do indeed operate on
Here this is just an I/O operation which does not actually need to consume the stream by any means. |
I can see that it might require more code to manage the different types of streams in one structure, though I view this cost as worth it. I can appreciate that this view is not the only possible one. Do you have any thoughts on how this sort of static guarantee can be maintained while lessening the burden on a programmer who wants to keep some closed and some open streams in one structure without decorating them as such? |
Conflicts: src/libstd/io/net/pipe.rs
I could add a type that exposes an interface similar to the current one in which |
I don't personally have a great idea in mind for how to get this sort of static guarantee, but I'll reference my comment on your other PR for pipes to stress that we need to consider the design of |
Sounds good to me! |
Here's an implementation for TCP streams that uses generics rather than traits: https://github.com/jbapple/rust/compare/affine-tcp?expand=1 I'm not submitting a PR for this at the moment, in order to wait on the |
@aturon and I have had taken quite some time to look at |
Remove syntax editing from parenthesis computation
...ts (at compile time) future attempts to write to that variable.
This is also true for close_read.
Note that UnixStreams cloned from a variable on which close_* is called are not affected by this change. They have the same interface as before, in which reads and writes may fail due to the underlying stream being closed for that operation.