usb_enumeration

A cross platform Rust library that returns the vendor and product IDs of currently connected USB devices

Actions Status

Example

```rust let devices = usb_enumeration::enumerate();

println!("{:#?}", devices);

// Outputs: // [ // USBDevice { // id: "USB\VID0CE9&PID1220\0000000004BE", // vendorid: 3305, // productid: 4640, // description: Some( // "PicoScope 4000 series PC Oscilloscope", // ), // }, // USBDevice { // id: "USB\VID046D&PIDC52B\5&17411534&0&11", // vendorid: 1133, // productid: 50475, // description: Some( // "USB Composite Device", // ), // }, // USBDevice { // id: "USB\VID046D&PIDC52B&MI00\6&12D311A2&0&0000", // vendorid: 1133, // productid: 50475, // description: Some( // "Logitech USB Input Device", // ), // }, // etc... // ] You can also subscribe events using the `Observer`: rust use usbenumeration::{Observer, Event};

// Set the poll interval to 2 seconds let sub = Observer::new(2) .withvendorid(0x1234) .withproductid(0x5678) .subscribe();

// when sub is dropped, the background thread will close

for event in sub.rx_event.iter() { match event { Event::Initial(d) => println!("Initial devices: {:?}", d), Event::Connect(d) => println!("Connected device: {:?}", d), Event::Disconnect(d) => println!("Disconnected device: {:?}", d), } } ```

License: MIT