-
Notifications
You must be signed in to change notification settings - Fork 232
spi: enforce all traits have the same Error type. #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @therealprof (rust-highfive has picked a reviewer for you, use r? to override) |
Working HAL implementation for nRF chips here embassy-rs/embassy#552. Updating was quite straightforward as the HAL already used the same error type for all impls. No issues discovered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea to me.
Opinions @rust-embedded/hal?
2c40bbf
to
37edca7
Compare
Friendly ping @eldruin @therealprof @ryankurte I guess if no one has any concerns in 23 days it's good to go? Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
bors r+
338: digital: enforce all traits have the same Error type. r=therealprof a=Dirbaio Equivalent of #331 for GPIO traits. This one is a bit trickier, so it maybe warrants some discussion (this is the reason I've opened everything as separate PR's, sorry for the spam!): - The bounds on `IoPin` are becoming very cursed, but I *think* they're correct... Is there some HAL out there implementing it, so that I can verify this doesn't break it? - This forces the "input" and "output" errors to be the same. Perhaps we want to only unify Output and Input separately? In practice I don't think this will be an issue, as structs usually impl only Input or Output but not both (except with IoPin maybe?) Co-authored-by: Dario Nieuwenhuis <[email protected]>
337: serial: enforce all traits have the same Error type. r=therealprof a=Dirbaio Equivalent of #331 for serial. Co-authored-by: Dario Nieuwenhuis <[email protected]>
336: i2c: enforce all traits have the same Error type. r=therealprof a=Dirbaio Equivalent of #331 for i2c. Co-authored-by: Dario Nieuwenhuis <[email protected]>
Previously discussed in #323, split off to its own PR now.
This PR enforces all SPI trait impls for a given type use the same Error associated type, by moving it to its own ErrorType trait.
How breaking is this?
I believe this is not very breaking in practice (it won't make upgrading existing code to 1.0 harder), because:
SpiWriteError, SpiReadError, SpiTransferError, SpiTransactionalError
...Why is this good?
Traits being able to have different Error types is IMO a case of "bad freedom" for the HALs. Today's traits don't stop HALs from implementing them with different error types, but this would cause them to be incompatible with drivers with these bounds. If traits force error types to be the same, the problem is gone.
What about other traits?
I believe this should be also applied to the other traits. I propose discussing this in the context of SPI here, and if the consensus is it's good I'll send PRs doing the same for the other traits.