Interfacing with USB devices in Rust?

Viewed 4596

I'm trying to figure out how to interface with a USB device in Rust. Does anyone have a solution? I found a package called usb-rust, but it was deprecated.

2 Answers

There are a number of wrappers to the C libusb library, including libusb and usb I haven't used either yet, but since your question came up first in my search, I thought I'd log these two answers here.

Editing in 2022, neither libusb-rs, rust-usb have been updated to the current version of Rust, but as another answer points out, rusb is very much active, builds libusb as part of installation, and wraps resources so they automatically get closed via RAII. Nice!

I tried to use the usb and libusb crates, but couldn't get my program to build correctly with the VS 2019 toolchain. rusb seems to have (roughly?) the same interface but downloads and builds libusb automatically, which worked for me without additional configuration.

Related