-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add error traits for communication interfaces #296
Conversation
r? @therealprof (rust-highfive has picked a reviewer for you, use r? to override) |
5068535
to
bb1dbe8
Compare
@eldruin Is this in line with the plans of the Rust error handling project group? Haven't had time to check, just making sure that we're not working contrary to what's coming up in upstream Rust... |
Good point. The only thing this proposal does is requiring that whatever error type the HAL implementation returns, a mapping to a set of common error variants exists, upon which generic drivers can act. |
this seems to me like a good synthesis of the work in the related issue! as with @therealprof i wonder how this aligns with the error-handling WG and existing it doesn't seem like it'd be useful to enforce those bounds through our API, but, it might be helpful to add (feature-gated) implementations for either |
d1fdfc8
to
024631b
Compare
Hmm, If those HAL-defined error types implement I have implemented |
I believe there was talk about allowing |
024631b
to
a0b86f2
Compare
HALs can indeed use A different topic would be implementing |
This PR is just waiting for a final review and a quick update to update the change-log, correct? |
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.
Thanks for the proposal, I like it. It's a lightweight approach that provides flexibility for HALs to define their custom error types, while at the same time offering a possibility to map custom errors to a standardized set of error types.
ed105ef
to
f16b10c
Compare
+1 to having official "error kinds" that generic drivers can react to. This is sorely needed! Maybe this PR should enforce that the |
f16b10c
to
adf490e
Compare
@Dirbaio @yodaldevoid I missed re-adding the |
4e8dbb3
to
f7ab7b1
Compare
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.
I've commented some bikeshedding on the error enums :)
Still not too much of a fan of the |
Is this still awaiting further reviews? |
d660d7b
to
3badfec
Compare
29c01a5
to
c3f07fe
Compare
c3f07fe
to
d870969
Compare
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
🎉 |
🎉 thank you @eldruin! |
316: I2C NACK error nesting r=therealprof a=yodaldevoid This idea was first proposed [here](#296 (comment)), but broken out to keep things moving. This merges `ErrorKind::NoAcknowledgeData` and `ErrorKind::NoAcknowledgeAddress` into one variant with a source field to indicate what the NACK was in response to. Some drivers may not be able to differentiate between NACKs on address or data bytes so they should use `NoAcknowledgeSource::Unknown`. Feel free to bikeshed names and documentation. I used the most obvious names to me, but naming is one of the hardest problems in programming. Co-authored-by: Gabriel Smith <ga29smith@gmail.com>
There has been a lengthy discussion about this in #229.
This implements proposal 3 by @TeXitoi which was the latest for I2C, SPI and Serial interfaces.
See here for the analysis
I included a minimal number of variants for each protocol, mostly borrowed from
embedded-error
.This raises the MSRV to Rust 1.40.0 as well in order to mark the
ErrorKind
s as#[non_exhaustive]
so that adding a new variant is not a breaking change.I am also fine with not marking the
ErrorKind
s as#[non_exhaustive]
.Closes #229