I think the
read_exact method on
std::io::Read is missing a fairly important signal: 0 bytes were read into the buffer and an EOF was encountered.
For example, you might be reading a file of fixed-size records, and you want to either read an entire record, or know you’ve reached EOF and no data is left to read (note: you need to read from a stream to know whether you’re at EOF or not), or signal something like “incomplete record at end file”. Currently,
read_exact will return
UnexpectedEof in both of these last two cases, even though in the former case an EOF might not at all be unexpected.
Should an additional error code be added to indicate this?