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

Support for embedded-hal 1.0.0 and async #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

bbustin
Copy link

@bbustin bbustin commented Mar 19, 2024

This pull request starts with the changes made by @madmo in his pull request (#3).

It then takes ideas from the pull request @tazz4843 has for adding async support (#2). It differs in two main ways:

  • The async feature is used as a toggle instead of having a blocking feature and an async feature
  • The signature is now the same due to @madmo's work updating it to embedded-hal 1.0.0. This allowed for putting blocking and async code in the same impl. This should make it easier to maintain in the future as each async fn is right next to its blocking counterpart.

I hope this is helpful. I initially created a pull request into @madmo's branch, but I have not heard back and it kind of muddies the intent of his pull request as its scope was only embedded-hal 1.0.0 and not async.

madmo and others added 5 commits February 20, 2024 10:32
…n the work by @tazz4843. The reason I did not use his branch is that I wanted this to be based on embedded-hal-1.0.0. Since the signatures changed, this allowed for puttign all the methods in the same impl block and then feature gating them.
- information about async feature
- use of embedded-hal 1.0.0
- updated the example
@bbustin
Copy link
Author

bbustin commented Sep 5, 2024

@sirhcell, is there anything you'd like changed? I'd love to get this pull request merged in, if you think it is ok.

@dylif
Copy link

dylif commented Sep 28, 2024

@sirhcel It would be great if you could approve this PR and get this merged in. Thank you for your consideration!

@bbustin
Copy link
Author

bbustin commented Sep 29, 2024

I have temporarily forked this project and published crate sht4x-ng.

That means the cargo.toml in this pull request would need to be edited to put back the original name. I would still love to see these changes upstreamed.

@sirhcel
Copy link
Owner

sirhcel commented Oct 13, 2024

Thank you very much for your PR! I finally managed to also look into the async part of it.

It took me a while because adding async support to an existing driver still feels a bit alienating. The support for it got better with maybe-async and maybe-async-cfg since I looked at #1 and #2 last time. But neither of the two buys us out for an embedded-hal driver yet as far as I can tell.

I really don't like the code duplication associated with it. But massaging maybe-async-cfg into working with the type parameters of the drivers struct is beyond my current schedule and "pay grade" - and so it looks like duplicating code is the way to go in the short term.

@sirhcell, is there anything you'd like changed? I'd love to get this pull request merged in, if you think it is ok.

To my understanding, Cargo features should be additive. A feature switching between sync and async will break in a dependency tree where both variants are used. So I would prefer always providing sync support and enabling async support with the feature async and providing the async variant of the driver as Sht4xAsync. Which at a first glance boils the changes down to #7.

What are your points for the toggling feature flag?

I definitely see the benefit of having sync and async methods spatially next to each other. But from my experience with dependency trees, this would be payed with a lot of potential hassle in dependency trees. And the latter will be "payed" by the users and not the authors of this crate.

@bbustin
Copy link
Author

bbustin commented Oct 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants