docs: add spec for removing rusb backend and lib/examples

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Davíð Steinn Geirsson 2026-03-25 13:17:12 +00:00
parent 2a8247c909
commit 8002dfa9e5

View file

@ -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<F>(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<GlobalContext>)` to `FnMut(&nusb::DeviceInfo)`.
### 5. Verification
- `cargo build` succeeds
- `cargo test` passes
- No remaining references to `rusb` in source files