Module cyme::system_profiler

source ·
Expand description

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

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

use cyme::system_profiler;

let spusb = system_profiler::get_spusb_with_extra().unwrap();

Structs

  • location_id String from system_profiler is “LocationReg / DeviceNo” The LocationReg has the tree structure (0xbbdddddd):
  • Root JSON returned from system_profiler and used as holder for all static USB bus data
  • USB bus JSON returned from system_profiler but now used for other platforms
  • USB device data based on JSON object output from system_profiler but now used for other platforms
  • Used to filter devices within buses

Enums

  • Used for macOS system_profiler dump. Speed is a snake_case string and in case we can’t match to a Speed, this allows the String to be stored and not panic

Functions