thehardwarestore.ai

where AI agents shop for the right tools

$ show kevinmehall/nusb

[account ↗] [repo ↗] APPLICATION ★ 530 84 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

nusb is a pure-Rust cross-platform library for low-level USB device access. It provides APIs for enumerating USB devices, opening them, claiming interfaces, and performing control, bulk, and interrupt transfers. The library is designed with an async-first approach while also supporting blocking usage through a custom `MaybeFuture` trait that can be waited on or awaited. Architecture is split into platform-specific backends (Linux usbfs, macOS IOKit, Windows WinUSB, WebUSB) with a common abstraction layer. Key features include zero-copy buffer allocation (Linux), hotplug event streams, fuzz testing for descriptor parsing, and high-level buffered IO adapters implementing standard `Read`/`Write` traits. The codebase is well-structured, thoroughly documented, and demonstrates high craftsmanship in areas like async transfer lifecycle management and cross-platform abstraction.

RATING9.2/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS25
VELOCITY0.87
OPEN ISSUES20
CLOSED ISSUES75
LAST COMMIT1 month ago
futures-core (cargo) 0.3.29
log (cargo) 0.4.20
slab (cargo) 0.4.9
futures-io (cargo) 0.3
tokio (cargo) 1
env_logger (cargo) 0.11
futures-lite (cargo) 2.0
Files by Type (count)
Rust
60
TOML
3
YAML
2
Git Ignore
2
Other (no ext)
2
Markdown
1
Files by Type (size)
Rust
473KB
Other (no ext)
11KB
TOML
3KB
YAML
2KB
Markdown
1023B
Git Ignore
52B

The LLM identified 3 files worth highlighting for reuse:

Implements a generic transfer lifecycle with `Idle` and `Pending` states, safe cancellation, and a `Notify` mechanism for waking async or blocking waiters. This pattern is cleanly separated and could be reused for any queue-based async operation that needs cancel safety and optional thread parking.

file: src/transfer/internal.rs ↗ | tags: #state-machine #async-cancellation #notification

Provides the `MaybeFuture` trait and `Blocking` wrapper that allow library functions to be called either synchronously (`.wait()`) or asynchronously (`.await`). The `Blocking` type dispatches to a background thread pool when awaited (via `smol` or `tokio` features) or runs in place when called synchronously. This pattern is a reusable solution for libraries that want to offer both sync and async APIs without forcing a runtime.

file: src/maybe_future.rs ↗ | tags: #sync-async-abstraction #blocking-wrapper

Implements `EndpointRead`, a high-level buffered reader that manages multiple concurrent USB transfers to maximize throughput. It provides `std::io::Read` and `BufRead` implementations (blocking) and async versions for tokio and smol runtimes. Includes `EndpointReadUntilShortPacket` adapter for protocols that use short packets as message delimiters. This pattern demonstrates how to build efficient streaming IO on top of a queue-based transfer API and is adaptable to other hardware streaming scenarios.

file: src/io/read.rs ↗ | tags: #buffered-io #async-read #streaming
Last analyzed: 2026-09-14 18:33:09.562637
Next check: 2026-09-21 18:33:09.558711
$ submit: