Skip to content
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

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft

Conversation

SergioGasquez
Copy link
Member

@SergioGasquez SergioGasquez commented Jan 3, 2025

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 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

This PR modifies spi/uart/timer to remove some nb::Results and embedded-hal-nb stuff.

Testing

Describe how you tested your changes.

Closes #2729
Closes #2730

@SergioGasquez SergioGasquez force-pushed the feat/remove-nb branch 2 times, most recently from c0e99a3 to 34ea519 Compare January 3, 2025 14:15
esp-hal/Cargo.toml Outdated Show resolved Hide resolved
@SergioGasquez SergioGasquez force-pushed the feat/remove-nb branch 3 times, most recently from 6cf562b to 8bf7839 Compare January 3, 2025 15:26
}

fn flush_data(&mut self) -> nb::Result<(), Infallible> {
fn flush_data(&mut self) -> Option<()> {
Copy link
Member

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?

Copy link
Collaborator

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

@@ -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,
Copy link
Contributor

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.

@@ -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> {
Copy link
Contributor

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.

esp-hal/src/uart.rs Outdated Show resolved Hide resolved
esp-hal/src/timer/mod.rs Outdated Show resolved Hide resolved
@SergioGasquez SergioGasquez force-pushed the feat/remove-nb branch 3 times, most recently from a3177e2 to 211fe06 Compare January 9, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants