Skip to content

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

Closed
@mahkoh

Description

@mahkoh

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]>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions