From 65dad9c01f3b56901f327569a89899d9f1d9b7e7 Mon Sep 17 00:00:00 2001 From: bochaco Date: Fri, 15 Dec 2023 19:13:31 -0300 Subject: [PATCH] fix: use of GenericDevice variants were not always behind corresponding transport feature flags --- lib/src/transport/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/src/transport/mod.rs b/lib/src/transport/mod.rs index 943f30a..295aa30 100644 --- a/lib/src/transport/mod.rs +++ b/lib/src/transport/mod.rs @@ -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; @@ -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 { 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, } } @@ -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, } }