Sensirion / sensirion-i2c-rs

Rust library with common functionality for our I2C sensors
BSD 3-Clause "New" or "Revised" License
12 stars 8 forks source link

Add support for `embedded-hal-async` #30

Closed hawkw closed 5 months ago

hawkw commented 5 months ago

Now that the embedded-hal-async crate has released version 1.0, it would be nice to be able to use the async versions of embedded-hal's traits for writing drivers for Sensirion I2C devices. This commit adds a new i2c_async module which provides versions of the APIs in the i2c module that use embedded-hal-async's async I2c trait rather than embedded-hal's blocking I2c trait.

The new module is feature-flagged, so that users who don't need embedded-hal-async support can avoid the additional dependency, and it's off by default. Ideally, it would be nice if the blocking embedded-hal APIs could also be feature-flagged, so that async-only users don't have to pull them in, but that would be a breaking change. I've also taken the liberty of adding support for the doc_cfg and doc_auto_cfg RustDoc features when building on docs.rs, so that the documentation displays that the new module is feature-flagged.

Closes #24

psachs commented 5 months ago

Thank you very much for your contribution

dbrgn commented 4 months ago

Hey @psachs, thanks for maintaining this crate! I noticed that this PR was merged, but no release was pushed to crates.io so far. Would you mind doing such a release? That would allow async support for the SGP30 to get merged: https://github.com/dbrgn/sgp30-rs/pull/19

psachs commented 3 months ago

@dbrgn I just release v0.4.0 with the async support. You should now be able to merge the sgp30 async support as well

dbrgn commented 3 months ago

@psachs great, thanks!