#connected #usb-device #drive #usb #history #enumerate

usbenum

A cross platform library that can enumerate USB devices currently connected and get connection history

1 unstable release

0.1.0 Aug 23, 2021

#1975 in Hardware support

Custom license

21KB
279 lines

Contains (Zip file, 7KB) usbenum.zip

USBENUM

Usb Enumeration is a cross-platform library that can enumerate USB devices currently connected and get connection history

Requirements

  • Rust 1.52+

Usage

  • Add to depedencies
[dependencies]
usbenum = "0.1.0"

and then

use usbenum::list_connected_usb_drives;

fn main() {
    match list_connected_usb_drives() {
        Ok(l) => {
            if l.is_empty() {
                println!("No currently connected usb drives")
            } else {
                println!("{:#?}", l)
            }
        }
        Err(e) => println!("{:?}", e),
    }
}
  • Running the example: cargo run --example connected_drives

License: MIT


lib.rs:

Get a list of currently connected USB drives

Example

use usbenum::list_connected_usb_drives;

match list_connected_usb_drives() {
    Ok(l) => println!("{:?}", l),
    Err(e) => println!("Error: {:?}", e),
}

Dependencies

~0.3–1.3MB
~25K SLoC