From 8002dfa9e5583453347c71ade0c72d858966c48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=AD=C3=B0=20Steinn=20Geirsson?= Date: Wed, 25 Mar 2026 13:17:12 +0000 Subject: [PATCH] docs: add spec for removing rusb backend and lib/examples Co-Authored-By: Claude Opus 4.6 (1M context) --- .../2026-03-25-remove-rusb-backend-design.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 docs/superpowers/specs/2026-03-25-remove-rusb-backend-design.md diff --git a/docs/superpowers/specs/2026-03-25-remove-rusb-backend-design.md b/docs/superpowers/specs/2026-03-25-remove-rusb-backend-design.md new file mode 100644 index 0000000..eb1dd93 --- /dev/null +++ b/docs/superpowers/specs/2026-03-25-remove-rusb-backend-design.md @@ -0,0 +1,59 @@ +# Remove rusb Backend and lib/examples + +**Date:** 2026-03-25 +**Status:** Approved + +## Problem + +The codebase carries two USB host backends (rusb and nusb) and a `lib/examples/` directory from the original upstream project. The rusb backend doesn't support isochronous transfers, is no longer used by the CLI, and duplicates functionality that nusb handles fully. The examples are unused leftovers. + +## Changes + +### 1. Delete `lib/examples/` + +Remove the entire directory containing `cdc_acm_serial.rs`, `hid_keyboard.rs`, and `host.rs`. + +### 2. Remove rusb from `lib/Cargo.toml` + +- Delete the `rusb = "0.9.3"` dependency +- Fix the `serde` feature from `["dep:serde", "rusb/serde"]` to `["dep:serde"]` + +### 3. Remove rusb types from `lib/src/host.rs` + +Delete `RusbUsbHostInterfaceHandler` (struct + `UsbInterfaceHandler` impl) and `RusbUsbHostDeviceHandler` (struct + `UsbDeviceHandler` impl). Keep `nusb_speed_to_linux()` and both `NusbUsbHost*Handler` types unchanged. + +### 4. Replace rusb enumeration in `lib/src/lib.rs` + +- Remove `use rusb::*` +- Delete `with_rusb_device_handles()` and `with_rusb_devices()` +- Rewrite `new_from_host()` and `new_from_host_with_filter()` to use nusb: + +```rust +pub fn new_from_host() -> Self { + Self::new_from_host_with_filter(|_| true) +} + +pub fn new_from_host_with_filter(filter: F) -> Self +where + F: FnMut(&nusb::DeviceInfo) -> bool, +{ + match nusb::list_devices().wait() { + Ok(list) => { + let devs: Vec<_> = list.filter(filter).collect(); + Self { + available_devices: RwLock::new(Self::with_nusb_devices(devs)), + ..Default::default() + } + } + Err(_) => Default::default(), + } +} +``` + +The filter type changes from `FnMut(&rusb::Device)` to `FnMut(&nusb::DeviceInfo)`. + +### 5. Verification + +- `cargo build` succeeds +- `cargo test` passes +- No remaining references to `rusb` in source files