-
Notifications
You must be signed in to change notification settings - Fork 226
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
Remove nb crate #2882
base: main
Are you sure you want to change the base?
Remove nb crate #2882
Conversation
c0e99a3
to
34ea519
Compare
6cf562b
to
8bf7839
Compare
esp-hal/src/hmac.rs
Outdated
} | ||
|
||
fn flush_data(&mut self) -> nb::Result<(), Infallible> { | ||
fn flush_data(&mut self) -> Option<()> { |
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.
This applies to other drivers as well, but Option<()>
as a return type feels a bit wrong to me. Perhaps we should just block instead, given that these are blocking APIs to begin with?
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'd say it's better to return Boolean rather than block. Gives users more options/flexibility
esp-hal/src/uart.rs
Outdated
@@ -285,6 +285,9 @@ pub enum Error { | |||
/// match the expected parity configuration. | |||
/// with the `async` feature. | |||
RxParityError, | |||
|
|||
/// This operation requires blocking behavior to complete | |||
WouldBlock, |
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 don't think we need this error. Usual Write
semantics just return a number of bytes written, and this PR already refactors reads into Options in most places. You're pretty much only using this error where a usize
would be enough, or where you still use the nb
crate.
esp-hal/src/uart.rs
Outdated
@@ -1392,8 +1399,9 @@ where | |||
T: Instance, | |||
Dm: DriverMode, | |||
{ | |||
fn read(&mut self) -> nb::Result<u8, Self::Error> { | |||
fn read(&mut self) -> embedded_hal_nb::nb::Result<u8, Self::Error> { |
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.
So are we removing nb
or are we not removing nb
? :D You can just drop these impls.
8bf7839
to
149e7ac
Compare
…void using block!
a3177e2
to
211fe06
Compare
211fe06
to
4652d56
Compare
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
This PR modifies spi/uart/timer to remove some nb::Results and embedded-hal-nb stuff.
read_byte
/write_byte
are now blocking for uart and spi.read_bytes
/write_bytes
return how many bytes they read/wrote.Testing
Describe how you tested your changes.
Closes #2729
Closes #2730