这是indexloc提供的服务,不要输入任何密码
Skip to content

16550 UART driver FLAGRANTLY DISREGARDS doc comment on Read trait #549

@iximeow

Description

@iximeow

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions