Skip to content

Make unused dependencies optional #118

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

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- Added async `DelayNs` implementation for `tokio`.
- Added feature flag for `serial`.

## [v0.4.0] - 2024-01-10

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ edition = "2018"
gpio_sysfs = ["sysfs_gpio"]
gpio_cdev = ["gpio-cdev"]
async-tokio = ["gpio-cdev/async-tokio", "dep:embedded-hal-async", "tokio/time"]
i2c = ["i2cdev"]
i2c = ["i2cdev", "nix"]
spi = ["spidev"]
serial = ["serialport", "embedded-hal-nb"]

default = [ "gpio_cdev", "gpio_sysfs", "i2c", "spi" ]
default = [ "gpio_cdev", "gpio_sysfs", "i2c", "spi", "serial" ]

[dependencies]
embedded-hal = "1"
embedded-hal-nb = "1"
embedded-hal-nb = { version = "1", optional = true }
embedded-hal-async = { version = "1", optional = true }
gpio-cdev = { version = "0.6.0", optional = true }
sysfs_gpio = { version = "0.6.1", optional = true }
i2cdev = { version = "0.6.0", optional = true }
nb = "1"
serialport = { version = "4.2.0", default-features = false }
serialport = { version = "4.2.0", default-features = false, optional = true }
spidev = { version = "0.6.0", optional = true }
nix = "0.27.1"
nix = { version = "0.27.1", optional = true }
tokio = { version = "1", default-features = false, optional = true }

[dev-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[cfg(feature = "i2c")]
pub use i2cdev;
pub use nb;
#[cfg(feature = "serial")]
pub use serialport;
#[cfg(feature = "spi")]
pub use spidev;
Expand Down Expand Up @@ -43,6 +44,7 @@ pub use sysfs_pin::{SysfsPin, SysfsPinError};
mod delay;
#[cfg(feature = "i2c")]
mod i2c;
#[cfg(feature = "serial")]
mod serial;
#[cfg(feature = "spi")]
mod spi;
Expand All @@ -51,6 +53,7 @@ mod timer;
pub use crate::delay::Delay;
#[cfg(feature = "i2c")]
pub use crate::i2c::{I2CError, I2cdev};
#[cfg(feature = "serial")]
pub use crate::serial::{Serial, SerialError};
#[cfg(feature = "spi")]
pub use crate::spi::{SPIError, SpidevBus, SpidevDevice};
Expand Down