16550 UART driver FLAGRANTLY DISREGARDS doc comment on Read trait
when used for non-blocking reads anyway. we've got this:
```
impl io::Read for Lock<'_, Nonblocking> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
for byte in buf.iter_mut() {
*byte = self.inner.read_nonblocking()?;
}
Ok(buf.len())
}
}
```
but on `trait mycelium_util::io::Read:
```
/// # Errors
///
/// If this function encounters any form of I/O or other error, an error
/// variant will be returned. If an error is returned then it must be
/// guaranteed that no bytes were read.
```
so if we're reading a buffer of size >1 and there's an error (say, no more data to read so you WouldBlock), we drop the read bytes on the floor. here i think we'd be ok by returning however many bytes _were_ read until the WouldBlock, if that was the error, but i think in general we probably want a more verbose read() variant that always returns like, `(usize, Result<(), Error>)` or something. (i did exactly the same thing as `myceium_util::io::Read`'s requirement in yaxpeax's reader type because posix brain lol)
0 条评论