@@ -26,12 +26,12 @@ 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::ShortRead, will be
30
- returned. In the event of another error, that error will be
29
+ of Ok(0) from read()), a new error type, ErrorKind::ShortRead(usize),
30
+ will be returned. ShortRead includes the number of bytes successfully
31
+ read. In the event of another error, that error will be
31
32
returned. After a read call returns having successfully read some
32
- bytes, the total number of bytes read will be updated. If that
33
- total is equal to the size of the buffer, read will return
34
- successfully.
33
+ bytes, the total number of bytes read will be updated. If that total
34
+ is equal to the size of the buffer, read will return successfully.
35
35
36
36
# Drawbacks
37
37
@@ -46,9 +46,9 @@ 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 .
49
+ If we wanted io::Error to be a smaller type, ErrorKind::ShortRead
50
+ could be unparameterized . But this would reduce the information
51
+ available to calleres .
52
52
53
53
Finally, in the event of a short read, we could return Ok(number of
54
54
bytes read before EOF) instead of an error. But then every user would
0 commit comments