fix: gate nusb/hardware discovery to Linux/macOS/Windows only

Android (Termux) reports target_os="android" which is not supported
by nusb::list_devices(). This caused E0425 and E0282 compile errors
when building on Termux.

Changes:
- Cargo.toml: move nusb to a target-gated dependency block so it is
  only compiled on linux/macos/windows
- src/hardware/discover.rs: add #![cfg(...)] file-level gate matching
  the nusb platform support matrix
- src/hardware/mod.rs: gate discover/introspect module declarations,
  discover_hardware() call, handle_command() dispatch, and all helper
  fns on the same platform set; add a clear user-facing message on
  unsupported platforms
- src/security/pairing.rs: replace deprecated rand::thread_rng() with
  rand::rng() to keep clippy -D warnings clean

Fixes #880
This commit is contained in:
argenis de la rosa 2026-02-18 23:44:20 -05:00 committed by Chummy
parent ba500a606e
commit a03ddc3ace
3 changed files with 29 additions and 12 deletions

View file

@ -1,4 +1,10 @@
//! USB device discovery — enumerate devices and enrich with board registry.
//!
//! USB enumeration via `nusb` is only supported on Linux, macOS, and Windows.
//! On Android (Termux) and other unsupported platforms this module is excluded
//! from compilation; callers in `hardware/mod.rs` fall back to an empty result.
#![cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
use super::registry;
use anyhow::Result;