Closed Kixunil closed 7 years ago
Although standard, there is information loss which I don't think is a good thing. We could certainly define a transformation into an io Error for an i2c error, but I'm not convinced it makes sense to start with that information loss.
I agree with @posborne - because the I2C driver can interact with more than just a file stream, making io::Error
the default would potentially mask errors. There is already a From
impl for LinuxI2CError
, so converting to an io::Error
is as simple as a io::Error::from(<error>)
or <error>.into()
I move to close this issue unless there's a different compelling reason to convert.
I prefer not losing error information too. I find io::Error
somewhat unfortunate decision. I like how I2CDevice
trait expresses it. However, it might still be desirable to make the conversion. What do you think about adding another bound to guarantee that Error
can be inspected somehow?
For example some trait (let's say I2CError
) with fn error_kind() -> ErrorKind
(It may be io::ErrorKind
or something custom). Then blanket impl <T: I2CError> From<T> for io::Error
could be writen too.
Thinking about it again and I believe the current state is good. Closing.
I believe it's better to use
io::Error
because it's standard for these kinds of operations. What do you think?