Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jul 20, 2024
1 parent 4c3f685 commit cb769b0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![No Std][no-std-badge]

This is a platform agnostic Rust driver for the Sensirion SGP30 gas sensor,
based on the [`embedded-hal`](https://github.com/japaric/embedded-hal) or
based on the [`embedded-hal`](https://github.com/rust-embedded/embedded-hal) or
[`embedded-hal-async`] traits.

Docs: https://docs.rs/sgp30
Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Set variables:

Update version numbers:

$ vim -p Cargo.toml
$ vim -p Cargo.toml src/lib.rs

Update changelog:

Expand Down
4 changes: 2 additions & 2 deletions src/async_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sensirion_i2c::i2c_async;
/// This type is identical to the [`Sgp30`](crate::Sgp30) type, but using the
/// [`embedded_hal_async`] versions of the [`I2c`] and [`DelayNs`] traits.
#[derive(Debug, Default)]
pub struct AsyncSgp30<I2C, D> {
pub struct Sgp30Async<I2C, D> {
/// The concrete I²C device implementation.
i2c: I2C,
/// The I²C device address.
Expand All @@ -19,7 +19,7 @@ pub struct AsyncSgp30<I2C, D> {
initialized: bool,
}

impl<I2C, D> AsyncSgp30<I2C, D>
impl<I2C, D> Sgp30Async<I2C, D>
where
I2C: I2c,
D: DelayNs,
Expand Down
19 changes: 16 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@
//! ```
//!
//! Once the `embedded-hal-async` feature is enabled, construct an instance of
//! the [`AsyncSgp30`] struct, providing types implementing the
//! the [`Sgp30Async`] struct, providing types implementing the
//! [`embedded_hal_async::i2c::I2c`] and [`embedded_hal_async::delay::DelayNs`]
//! traits. The [`AsyncSgp30`] struct is identical to the [`Sgp30`] struct,
//! traits. The [`Sgp30Async`] struct is identical to the [`Sgp30`] struct,
//! except that its methods are `async fn`s.
//!
//! [`embedded-hal-async`]: https://crates.io/crates/embedded-hal-async
Expand All @@ -205,7 +205,7 @@ use crate::hal::{
#[cfg(feature = "embedded-hal-async")]
mod async_impl;
#[cfg(feature = "embedded-hal-async")]
pub use async_impl::AsyncSgp30;
pub use async_impl::Sgp30Async;

mod types;

Expand Down Expand Up @@ -276,6 +276,19 @@ impl Command {
}
}

/// Writes this command and the provided `data` bytes to `buf`, returning a
/// slice of the written portion of `buf`.
///
/// # Arguments
///
/// - `buf`: The buffer into which to write the command and data bytes.
/// This buffer must be 8 bytes long.
/// - `data`: The data bytes to write after the command bytes. This slice
/// must contain either 2 or 4 bytes.
///
/// # Panics
///
/// - If `data` is not either 2 or 4 bytes long.
fn as_bytes_with_data<'buf>(self, buf: &'buf mut [u8; 8], data: &[u8]) -> &'buf [u8] {
assert!(data.len() == 2 || data.len() == 4);
buf[0..2].copy_from_slice(&self.as_bytes());
Expand Down

0 comments on commit cb769b0

Please sign in to comment.