From bb2c1eab65d13bad88b3d37d0097725e3b8616ab Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Wed, 3 Jun 2026 23:58:52 -0600 Subject: [PATCH] ble: satisfy peer feature clippy --- crates/rns-interface/src/ble_peer.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/rns-interface/src/ble_peer.rs b/crates/rns-interface/src/ble_peer.rs index 05453f3..5fcf60b 100644 --- a/crates/rns-interface/src/ble_peer.rs +++ b/crates/rns-interface/src/ble_peer.rs @@ -186,10 +186,12 @@ impl BlePeerLinkRegistry { } } + #[cfg(any(test, target_os = "android", target_os = "ios", target_os = "macos"))] fn address_for_writer_key<'a>(&self, writer_key: &'a str) -> &'a str { writer_key.strip_prefix("central:").unwrap_or(writer_key) } + #[cfg(any(test, target_os = "android", target_os = "ios", target_os = "macos"))] fn should_send_peripheral_subscriber( &self, subscriber_address: &str, @@ -217,11 +219,13 @@ impl BlePeerLinkRegistry { type LinkRegistry = Arc>; +#[cfg(any(test, target_os = "android", target_os = "ios", target_os = "macos"))] fn payload_needs_redundant_role_fanout(payload: &[u8]) -> bool { rns_wire::header::PacketHeader::unpack(payload) .is_ok_and(|(header, _)| header.flags.packet_type == rns_wire::flags::PacketType::Proof) } +#[cfg(any(test, target_os = "android", target_os = "ios", target_os = "macos"))] fn should_send_peripheral_payload( registry: &BlePeerLinkRegistry, subscriber_address: &str, @@ -515,15 +519,15 @@ pub(crate) fn running_flag() -> Arc { } static BLE_PEER_GENERATION: std::sync::OnceLock = std::sync::OnceLock::new(); -static BLE_PEER_CHILD_TASKS: std::sync::OnceLock< - std::sync::Mutex)>>, -> = std::sync::OnceLock::new(); +type BlePeerChildTask = (u64, tokio::task::JoinHandle<()>); +type BlePeerChildTasks = std::sync::Mutex>; +static BLE_PEER_CHILD_TASKS: std::sync::OnceLock = std::sync::OnceLock::new(); fn generation_counter() -> &'static AtomicU64 { BLE_PEER_GENERATION.get_or_init(|| AtomicU64::new(0)) } -fn child_tasks() -> &'static std::sync::Mutex)>> { +fn child_tasks() -> &'static BlePeerChildTasks { BLE_PEER_CHILD_TASKS.get_or_init(|| std::sync::Mutex::new(Vec::new())) } @@ -3953,14 +3957,6 @@ mod linux_peripheral { Ok(()) } - fn take_inbound_rx_init() { - // Cheap idempotent init so write callbacks always have a sender even - // before the consumer takes the receiver. - if inbound_sender().is_none() { - reset_inbound_channel(); - } - } - async fn build_service( service_uuid: Uuid, rx_uuid: Uuid, @@ -5292,6 +5288,7 @@ pub async fn spawn_ble_peer_interface( let txb_w = shared_txb.clone(); let writers_w = peer_writers.clone(); let anti_loop_fan = anti_loop.clone(); + #[cfg(any(target_os = "android", target_os = "ios", target_os = "macos"))] let link_registry_fan = link_registry.clone(); track_child_task( generation, @@ -5318,6 +5315,7 @@ pub async fn spawn_ble_peer_interface( .map(|(key, tx)| (key.clone(), tx.clone())) .collect::>() }; + #[cfg(any(target_os = "android", target_os = "ios", target_os = "macos"))] let central_writer_keys = writer_snapshot .iter() .map(|(key, _)| key.clone())