Implement Into<Infallible> when spi::DeviceError is infallible #718
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm currently writing a SPI device driver which can use any struct that implements
embedded_hal::spi::SpiDeviceinternally, such as aembedded_hal_bus::spi::ExclusiveDevice. I would like to provide an infallible API for platforms which have infallible SPI transactions, such as the RP2350. A SPI transaction on these platforms returnsResult<(), DeviceError<Infallible, Infallible>>if we use anExclusiveDevice, which can obviously be safely unwrapped.To write this API I create a simple wrapper struct around the original fallible API. I tried to constrain the error type by
Into<Infallible>such that any error type that is convertible toInfalliblecan be used. However,DeviceError<Infallible, Infallible>does not implement this trait yet. So I implemented it in this PR.Happy to hear opinions and possible alternatives, this was the first solution I saw.