@@ -26,7 +26,7 @@ read into, and will attempt to fill that entire slice with data.
26
26
It will loop, calling read() once per iteration and attempting to read
27
27
the remaining amount of data. If read returns EINTR, the loop will
28
28
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
30
30
returned. In the event of another error, that error will be
31
31
returned. After a read call returns having successfully read some
32
32
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
46
46
could report the number of bytes sucessfully read before an error.
47
47
This would be inconsistent with write_all, but arguably more correct.
48
48
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
+
49
58
Or we could leave this out, and let every Rust user write their own
50
59
read_all function -- like savages.
0 commit comments