-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #12 basic lib example; lib.rs doc example
- Loading branch information
Showing
7 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use cyme::lsusb::profiler; | ||
use cyme::display; | ||
|
||
fn main() -> Result<(), String> { | ||
// get all system devices - use get_spusb_with_extra for verbose info | ||
let sp_usb = profiler::get_spusb(false).map_err(|e| { | ||
format!("Failed to gather system USB data from libusb, Error({})", e) | ||
})?; | ||
|
||
// flatten since we don't care tree/buses | ||
let devices = sp_usb.flatten_devices(); | ||
|
||
// print with default [`display::PrintSettings`] | ||
display::print_flattened_devices(&devices, &display::PrintSettings::default()); | ||
|
||
// alternatively interate over devices and do something with them | ||
for device in devices { | ||
match (device.vendor_id, device.product_id) { | ||
(Some(0x05ac), Some(_)) => { | ||
println!("Found Apple device: {}", device); | ||
} | ||
_ => {} | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters