Skip to content

Commit

Permalink
Merge pull request #8 from bochaco/fix-ble-conditional-compilation
Browse files Browse the repository at this point in the history
fix: use of GenericDevice variants were not always behind corresponding transport feature flags
  • Loading branch information
ryankurte authored Sep 30, 2024
2 parents c46849b + 65dad9c commit 5173352
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
use std::{fmt::Debug, time::Duration};

use tracing::{debug, warn};
#[cfg(feature = "transport_ble")]
use tracing::warn;

use tracing::debug;

#[cfg(feature = "transport_usb")]
mod usb;
Expand Down Expand Up @@ -178,16 +181,22 @@ impl GenericDevice {
/// Fetch connection info for a device
pub fn info(&self) -> ConnInfo {
match self {
#[cfg(feature = "transport_usb")]
GenericDevice::Usb(d) => d.info.clone().into(),
#[cfg(feature = "transport_ble")]
GenericDevice::Ble(d) => d.info.clone().into(),
#[cfg(feature = "transport_tcp")]
GenericDevice::Tcp(d) => d.info.clone().into(),
}
}

pub(crate) async fn is_connected(&self) -> Result<bool, Error> {
match self {
#[cfg(feature = "transport_usb")]
GenericDevice::Usb(d) => d.is_connected().await,
#[cfg(feature = "transport_ble")]
GenericDevice::Ble(d) => d.is_connected().await,
#[cfg(feature = "transport_tcp")]
GenericDevice::Tcp(d) => d.is_connected().await,
}
}
Expand All @@ -200,7 +209,9 @@ impl Exchange for GenericDevice {
match self {
#[cfg(feature = "transport_usb")]
Self::Usb(d) => d.exchange(command, timeout).await,
#[cfg(feature = "transport_ble")]
Self::Ble(d) => d.exchange(command, timeout).await,
#[cfg(feature = "transport_tcp")]
Self::Tcp(d) => d.exchange(command, timeout).await,
}
}
Expand Down

0 comments on commit 5173352

Please sign in to comment.