Skip to content

Commit 6566a1d

Browse files
committed
address review comments
1 parent 288b1b5 commit 6566a1d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

text/0000-read-all.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ read into, and will attempt to fill that entire slice with data.
2626
It will loop, calling read() once per iteration and attempting to read
2727
the remaining amount of data. If read returns EINTR, the loop will
2828
retry. If there are no more bytes to read (as signalled by a return
29-
of Ok(0) from read()), a new error type, ErrorKind::ReadZero, will be
29+
of Ok(0) from read()), a new error type, ErrorKind::ShortRead, will be
3030
returned. In the event of another error, that error will be
3131
returned. After a read call returns having successfully read some
3232
bytes, the total number of bytes read will be updated. If that
@@ -46,5 +46,14 @@ One alternative design would return some new kind of Result which
4646
could report the number of bytes sucessfully read before an error.
4747
This would be inconsistent with write_all, but arguably more correct.
4848

49+
Another would be that ErrorKind::ShortRead would be parameterized by
50+
the number of bytes read before EOF. The downside of this is that it
51+
bloats the size of io::Error.
52+
53+
Finally, in the event of a short read, we could return Ok(number of
54+
bytes read before EOF) instead of an error. But then every user would
55+
have to check for this case. And it would be inconsistent with
56+
write_all.
57+
4958
Or we could leave this out, and let every Rust user write their own
5059
read_all function -- like savages.

0 commit comments

Comments
 (0)