Date: 2026-03-16
Repository: rustusblib
Branch: main
To analyze the codebase end-to-end, the review was split into focused "sub-agents":
- History agent: analyzed commit timeline and milestone sequence.
- API agent: audited
usb-lib/src/api/*and public exports inusb-lib/src/lib.rs. - Windows agent: audited
usb-lib/src/backend/windows.rsfeature coverage and build behavior. - Linux agent: audited
usb-lib/src/backend/linux.rsimplementation depth. - macOS agent: audited
usb-lib/src/backend/macos.rsimplementation depth. - Validation agent: ran build/test/lint commands and captured current blockers.
- Docs agent: compared README claims against the actual API and backend behavior.
97b4d5b- Scaffold created: crate layout, core types, API wrapper, error model.22db110- Windows backend: enumeration and open path implemented.b14c47d- Descriptor models/parsers: device/config/string/HID/BOS/hub/superspeed companion.1bcc204- Control transfer support and builder helpers.20405c5- Bulk and interrupt transfer support.af695d1- Pipe management: query/policy/reset/abort.62e07af- Interface management and endpoint cache.23d0dcc- Device reset via manual FFI binding.488f49f- Overlapped async transfer methods.7e58bf9- Hotplug support added.413ef70-.gitignoreupdate.cdd63de- Linux backend introduced (udev +USBDEVFS_CONTROL).3332c0b- macOS backend introduced (IOKit + IOUSBDevice interface path).9c79627- Isochronous transfers behind feature flag.69aeadf- Tokio integration behind feature flag.61934f2-DEVELOPMENT.mdadded.6e0cef6- README/docs commit.f056b4b- ignore updates.0ef15dc- HRESULT mapping and lint cleanup fixes.
Commands run on 2026-03-16:
cargo check-> passcargo check --features tokio-> passcargo check --features isochronous-> passcargo check --all-features-> passcargo clippy --all-features -- -D warnings-> passcargo test --lib-> pass (0 tests present)cargo test-> fail (example link failure)cargo build --examples-> fail (same link failure)
Current hard blocker:
- Windows GNU link fails with
undefined reference to WinUsb_ResetDevicefromwindows.rswhen examples/tests link. - macOS path parser expects
bus=but enumeration emitsiokit:bus=..., soopen()from enumerated path is likely broken.
Cross-platform compile validation limits on this machine:
- Installed targets:
x86_64-pc-windows-gnu,x86_64-unknown-linux-gnu. - Linux cross-check currently fails at
libudev-sysbuild step because crosspkg-configsysroot/tooling is not configured on this Windows host. cargo check --target x86_64-apple-darwinstill requires adding that target first.
| Capability | Windows | Linux | macOS | Status Notes |
|---|---|---|---|---|
| Device enumeration | Implemented | Implemented | Implemented | Native APIs used per OS |
| Device open/close | Implemented | Implemented | Implemented | macOS uses IOUSB interface plugin path |
| Device descriptor read | Implemented | Implemented | Implemented | |
| Config descriptor read | Implemented | Implemented | Implemented | two-pass in all backends |
| String descriptor read | Implemented | Implemented | Implemented | |
| Generic control transfer | Implemented | Implemented | Implemented | |
| Interface claim/release | Implemented | Implemented | Partial | macOS now validates + tracks claims via GET/SET_INTERFACE control path |
| Bulk transfers | Implemented | Implemented | Missing | Linux uses USBDEVFS_BULK |
| Interrupt transfers | Implemented | Implemented | Missing | Linux currently reuses the usbdevfs bulk-style path |
| Pipe reset/abort | Implemented | Implemented | Missing | Linux uses USBDEVFS_CLEAR_HALT/USBDEVFS_RESETEP |
| Alt setting get/set | Implemented | Implemented | Missing | Linux uses GET_INTERFACE + USBDEVFS_SETINTERFACE |
| Pipe policy get/set | Implemented | Kernel-limited (Unsupported) |
Missing | usbdevfs has no WinUSB-style pipe policy controls |
| Pipe info query | Implemented | Missing | Missing | |
| Device reset | Implemented (code) | Implemented | Missing | Windows still has a link blocker in example/test link |
| BOS descriptor read | Implemented | Missing | Missing | Linux/macOS not overridden |
| Hub descriptor read | Implemented | Missing | Missing | Linux/macOS not overridden |
| Async bulk/interrupt methods | Implemented | Implemented | Missing | Linux async methods currently map to timeout-based sync I/O |
| Isochronous transfer | Implemented (feature gated) | Implemented (feature gated) | Missing | Linux uses USBDEVFS_SUBMITURB + USBDEVFS_REAPURB |
| Hotplug callback | Implemented | Implemented | Missing | Linux uses udev monitor socket on a worker thread |
| Feature | Linux |
|---|---|
| Bulk/interrupt transfers | Implemented |
| Pipe reset/abort | Implemented |
| Async transfer path | Implemented (sync-backed) |
| Hotplug | Implemented |
| Interface claim/release | Implemented |
| Control transfer | Implemented |
| Descriptors | Implemented |
| Alt-setting get/set | Implemented |
| Pipe info | Implemented |
| Pipe policy | Kernel-limited (Unsupported) |
| Isochronous | Implemented (feature-gated) |
Core and API:
- Public context + device handle abstraction over
dyn UsbDevice. - Rich descriptor parsing module (
Device,Config,Interface,Endpoint,HID,BOS,Hub,SS Companion). - Control setup helper constructors.
- Pipe policy enums and endpoint info models.
- Error enum with Windows HRESULT mapping.
Windows backend:
- WinUSB enumeration via SetupAPI and interface GUID filtering.
- Open path with read-write and read-only fallback.
- Control, bulk, interrupt transfers.
- Interface claim/release plus endpoint-to-interface cache.
- Pipe reset/abort, alt setting get/set, pipe info query, pipe policy get/set.
- Device reset via manual FFI (
WinUsb_ResetDevice). - Async transfer paths via OVERLAPPED and wait-based completion.
- Feature-gated isochronous transfer helpers via manual FFI.
- String descriptor enrichment during enumeration.
Linux backend:
- udev enumeration.
- Open
/dev/bus/usb/...with read-write/read-only fallback. USBDEVFS_CONTROL-based control transfer path.- Interface claim/release via usbdevfs ioctls.
- Device/config/string descriptor read support.
- Bulk and interrupt transfers via
USBDEVFS_BULK. - Pipe reset and abort via
USBDEVFS_CLEAR_HALT/USBDEVFS_RESETEP. - Device reset via
USBDEVFS_RESET. - Alt-setting get/set via GET_INTERFACE +
USBDEVFS_SETINTERFACE. - Pipe info via endpoint descriptor cache.
- Pipe policy explicitly returns
Unsupported(kernel limitation). - Feature-gated isochronous support via
USBDEVFS_SUBMITURB/USBDEVFS_REAPURB. - Async transfer methods implemented as timeout-based sync wrappers.
macOS backend:
- IOKit enumeration over
IOUSBDeviceservices. - IOUSB device interface acquisition via plugin
QueryInterface. - Control transfers through
DeviceRequestTO. - Device/config/string descriptor read support.
parse_iokit_pathfixed foriokit:bus=...,addr=...paths.- Interface claim/release now implemented as non-no-op via interface validation + GET/SET_INTERFACE and claim tracking.
Async/hotplug:
- Tokio wrappers (feature-gated) around async transfer methods.
- Hotplug implementation on Windows via
CM_Register_Notification. - Linux hotplug implementation via
udev::MonitorBuilder+ poll loop worker thread. - Non-Windows/non-Linux hotplug remains
Unsupported.
- Fix Windows GNU link issue for
WinUsb_ResetDeviceso examples/tests link cleanly. - Add CI matrix for Windows/Linux/macOS compile checks.
- Add real tests (descriptor parser unit tests, backend behavior tests, API smoke tests).
- Sync README with actual API names and behavior.
- Add missing referenced docs/files (
CONTRIBUTING.md,LICENSE) or update README links.
- Resolve
WinUsb_ResetDevicelink reliability across toolchains. - Add test coverage for advanced operations (pipe policy, alt settings, async, isoch).
- Add hardware-backed integration test guide and compatibility matrix.
- Implement BOS/hub descriptor convenience methods (currently trait default).
- Add native async URB path if true non-blocking semantics are required (current async methods are sync-backed).
- Implement bulk/interrupt transfers via interface/pipe APIs.
- Implement alt-setting controls and pipe-level controls.
- Implement BOS/hub descriptor convenience methods.
- Implement async transfer path (or explicit unsupported contract).
- Implement macOS hotplug callback path.
- Bulk/interrupt (next)
- Alt-setting, pipe info/policy
- Hotplug
- Isochronous
Current README mismatches code behavior and API:
- Uses
ctx.list_devices()but API providesctx.devices(). - Uses
ctx.open_device(...)but API providesctx.open(...). - Uses
ControlSetup::new(...)andRequestType/Recipienttypes not present in current code. - Hotplug is now implemented on Linux but still unsupported on macOS.
- Example import path uses
usblibrwhile library exports asusb_libin code. - Tokio wrapper docs mention
spawn_blocking, but implementation usesblock_in_place.
- Stabilize Windows build/link (unblocks example and full test builds).
- Fix README/docs to match current API exactly.
- Add cross-platform CI compile gates.
- Validate Linux backend on a native Linux runner (real hardware + hotplug + transfer smoke tests).
- Deliver macOS bulk/interrupt + proper interface handling + hotplug.
- Add comprehensive automated tests after backend parity improves.
The project can be marked "cross-platform MVP complete" when all are true:
- Windows/Linux/macOS each support enumeration, open, descriptors, control, bulk, interrupt.
- Hotplug works on all three platforms.
- README/API/docs are consistent and runnable.
- CI passes on all three OSes.
- At least smoke-level tests exist for all public API groups.
- Examples build and run without linker/runtime blockers.