Skip to content
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

Disallow Readers that return Ok(0) from read #18079

Closed
mahkoh opened this issue Oct 15, 2014 · 2 comments
Closed

Disallow Readers that return Ok(0) from read #18079

mahkoh opened this issue Oct 15, 2014 · 2 comments

Comments

@mahkoh
Copy link
Contributor

mahkoh commented Oct 15, 2014

so that clients can assume that read returns a positive number of bytes read or an error. Here, error includes EOF (EndOfFile) and EAGAIN/EWOULDBLOCK (ResourceUnavailable).

The current docs already state that Reader implementation should never return Ok(0) if they can avoid it. This should be changed to a clear statement that Readers are never allowed to return Ok(0).

It's probably not possible to enforce this at compile- or runtime right now. If Rust gets types that can contain certain ranges of integers, the return type of read can be changed to IoResult<[1..UINT_MAX]>.

@huonw huonw added the A-libs label Oct 16, 2014
@nodakai
Copy link
Contributor

nodakai commented Oct 16, 2014

Regarding to the last paragraph:

@nick29581 has written a simplistic plugin for DbC, thougth I haven't played with it yet.

There was a discussion on the use of unsigned integers:

Google C++ style guide discouraging the use of unsigned drew my attention.

Also note that 32 bit Windows with 3G/1G split (4GT) is probably the only OS whose read(2)-like syscall can process more than ssize_max bytes at once.

@alexcrichton
Copy link
Member

This was fixed with the new std::io design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants