Skip to content

Commit

Permalink
example code for main imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Jan 9, 2023
1 parent d54ad7a commit e80c532
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
13 changes: 12 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "List system USB buses and devices; a modern and compatible `lsusb
repository = "https://github.com/tuna-f1sh/cyme"
readme = "README.md"
license = "GPL-3.0-or-later"
version = "1.2.1"
version = "1.2.2"
edition = "2021"
keywords = ["usb", "lsusb", "system_profiler", "macos", "libusb"]
categories = ["command-line-utilities"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Will cover this more as it develops. Use `cyme --help` for basic usage or `man .

## Crate

For usage as a library for profiling system USB devices, the crate is 100% documented so look at [docs.rs](https://docs.rs/cyme/latest/cyme/)
For usage as a library for profiling system USB devices, the crate is 100% documented so look at [docs.rs](https://docs.rs/cyme/latest/cyme/). The main useful modules for import are [system_profiler](https://docs.rs/cyme/latest/cyme/system_profiler/index.html), [lsusb::profiler](https://docs.rs/cyme/latest/cyme/lsusb/profiler/index.html) and [usb](https://docs.rs/cyme/latest/cyme/usb/index.html)

## Config

Expand Down
11 changes: 11 additions & 0 deletions src/lsusb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ pub mod profiler {
//! Uses rusb (upto date libusb fork) to get system USB information, most of which has parity with lsusb. Requires 'libusb' feature. Uses [`crate::system_profiler`] types to hold data so that it is cross-compatible with macOS system_profiler command.
//!
//! lsusb uses udev for tree building, which libusb does not have access to and is Linux only. udev-rs is used on Linux to attempt to mirror the output of lsusb on Linux. On other platforms, certain information like driver used cannot be obtained.
//!
//! Get [`system_profiler::SPUSBDataType`] struct of system USB buses and devices with extra data like configs, interfaces and endpoints
//! ```no_run
//! use cyme::lsusb::profiler;
//!
//! let spusb = profiler::get_spusb_with_extra().unwrap();
//! // print with alternative styling (#) is using utf-8 icons
//! println!("{:#}", spusb);
//! ```
//!
//! See [`system_profiler`] docs for what can be done with returned data, such as [`system_profiler::USBFilter`]
use std::collections::HashMap;
use std::time::Duration;
use itertools::Itertools;
Expand Down
16 changes: 16 additions & 0 deletions src/system_profiler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
//! Parser for macOS `system_profiler` command -json output with SPUSBDataType.
//!
//! USBBus and USBDevice structs are used as deserializers for serde. The JSON output with the -json flag is not really JSON; all values are String regardless of contained data so it requires some extra work. Additionally, some values differ slightly from the non json output such as the speed - it is a description rather than numerical.
//!
//! Get [`SPUSBDataType`] from macOS system_profiler and print
//! ```no_run
//! use cyme::system_profiler;
//!
//! let spusb = system_profiler::get_spusb().unwrap();
//! // print with alternative styling (#) is using utf-8 icons
//! println!("{:#}", spusb);
//! ```
//!
//! Get [`SPUSBDataType`] from macOS system_profiler and merge with extra data from libusb
//! ```no_run
//! use cyme::system_profiler;
//!
//! let spusb = system_profiler::get_spusb_with_extra().unwrap();
//! ```
use std::fmt;
use std::io;
use std::fs;
Expand Down

0 comments on commit e80c532

Please sign in to comment.