Description
Currently operations defined in the digital
module traits do not allow error propagation.
For example, in an I2C I/O expander driver I am writing I want to provide access to the individual pins as a bunch of Px
structs implementing OutputPin
and InputPin
. Setting a pin or reading it involves I2C communication, which could fail.
At the moment I just panic if there was a problem for either reading or writing.
The same would happen with the other traits: StatefulOutputPin
and ToggleableOutputPin
Another example from @caemor:
The only problem I found with this api since using it is that errors can't get propagated any further and need to be converted to a default value.
E.g. the linux sys_fs can receive an file error while trying to read the value (https://github.com/rust-embedded/rust-sysfs-gpio/blob/master/src/lib.rs#L337) and this can't be handled by a simple bool.
Discussion started here