10 releases

0.4.2 May 10, 2021
0.4.1 May 9, 2021
0.4.0 Apr 7, 2021
0.3.1 Mar 28, 2021
0.2.1 Sep 11, 2020

#1410 in Hardware support


Used in 2 crates

MIT license

58KB
1.5K SLoC

Native USB API for Rust

Inspired by the C http://libusb.info driver.

Rust usbapi crate currently only support Linux.

UsbAPI crate does not have any dependencies on libusb C API's and is a clean implementation in Rust using ioctl/mmap calls on Linux using nix low level crate.

You are free to fork or send pull request and make it work on other platforms.

Dependencies

See Cargo.toml I try to use as less as possible.

Supported functions in Linux

  • Enumerate USB peripherals
  • Zero copy using mmap buffers.
  • Sync bulk API's
  • Async bulk and control transmissions
  • Transfers are safe and can't be accessed after passed to kernel
  • Optional all descriptors can be serialized if feature serde is enabled.
  • Optional mio support

TODO

When I started this project I was new in Rust. Some stuff will change.

  • Cleanup traits implementations for easier port to other platforms
  • Use valgrind to cleanup possible leaks in unsafe code (eg mmap etc...
  • Add isochronous support
  • Add interrupt endpoints
  • Use log crate instead of eprintln and println for debug.
  • claim_interface will panic if kernel driver is loaded since unload driver is not implemented cant test so not implemented feel free to send patch if needed.

For those who use any of below platforms, feel free to send a pull request:

  • Support FreeBSD/OpenBSD
  • Support NetBSD
  • Support Haiku
  • Support OSX
  • Support Windows

Dependencies

~1.7–2.3MB
~48K SLoC