๐Ÿ“œ A pci.ids-compliant library for getting information about available PCI devices.

Overview

aparato

A pci.ids-compliant library for getting information about available PCI devices.

version docs

Usage

Add the following to your project's Cargo.toml file:

aparato = "3.0.0"

Examples

= PCIDevice::fetch(); println!("{:?}", detailed_list); // Return a list of the available PCI devices of a specific class. // -> "thing" holds a list of all the detected network controllers and their information. let thing: Vec = PCIDevice::fetch_by_class(DeviceClass::NetworkController); println!("{:?}", thing); } ">
use aparato::PCIDevice;
use aparato::classes::DeviceClass;
use aparato::traits::*;

fn main() {
    // Know the address domain of the PCI device?
    // Instantiate a new PCIDevice so we can get to know it a bit.
    let device: PCIDevice = PCIDevice::new("0000:00:02.0");

    println!("Class Name: {}", device.class_name());    // e.g. Display Controller
    println!("Vendor Name: {}", device.vendor_name());  // e.g. Intel Corporation
    println!("Device Name: {}", device.device_name());  // e.g. WhiskeyLake-U GT2 [UHD Graphics 620]

    // Alternatively, we can get information on PCI devices through fetching them in bulk!

    // Return a list of available PCI devices and their information.
    let detailed_list: Vec<PCIDevice> = PCIDevice::fetch();
    println!("{:?}", detailed_list);

    // Return a list of the available PCI devices of a specific class.
    // -> "thing" holds a list of all the detected network controllers and their information.
    let thing: Vec<PCIDevice> = PCIDevice::fetch_by_class(DeviceClass::NetworkController);
    println!("{:?}", thing);
}

Platform Support
Linux โœ“
Windows
macOS
NetBSD

aparato is still a work in progress.

Comments
  • Use integers rather than `String` for `PCIDevice` `x_id` fields.

    Use integers rather than `String` for `PCIDevice` `x_id` fields.

    What?

    The following fields could be represented as integers:

    class_id: String -> class_id: usize
    vendor_id: String -> vendor_id: usize
    device_id: String -> device_id: usize
    // Spoilers ahead!
    subsystem_vendor_id: String -> subsystem_vendor_id: usize
    subsystem_device_id: String -> subsystem_device_id: usize
    

    Why?

    Using String for fields that may as well be integers, is very expensive.

    optimization 
    opened by grtcdr 3
  • Reimplement `Fetch`

    Reimplement `Fetch`

    In version 5.0, the Linux implementation of Fetch was removed so it could be reworked. It will now be reimplemented but with performance in mind.

    What must be done different?

    • Fetch::fetch_by_class() in previous versions would create a PCIDevice out of every PCI device it could find, then and only then, does it remove the irrelevant PCI devices, and this costs time and is so inefficient it literally blows my mind why I decided to implement it the way I did.

    Nice-To-Haves

    • A new method, something along the lines of Fetch::fetch_by_subclass(name) where name is of type String. This method should return only the PCI devices whose subclass (click any click to see subclasses) is equal to what was provided to the method. It is unmaintainable for me to provide an enum with ready-to-use subclasses, because there's well over 50 of these, and they're always changing.
    bug 
    opened by grtcdr 1
  • Improve pci.ids parsing

    Improve pci.ids parsing

    Addressing slowness

    aparato runs really, really slooow when fetching PCI devices in bulk, through fetch(), fetch_by_class() or fetch_gpus() If you're instantiating one PCI device, the performance is acceptable (around 3-5ms), but when you're fetching multiple devices, that's when you notice how slow it can get (around 80-90ms).

    help wanted optimization 
    opened by grtcdr 1
  • PCIDevice::fetch_by_class() returning nothing

    PCIDevice::fetch_by_class() returning nothing

    Description

    fetch_by_class() appears to be broken (returns nothing), passing any variant of DeviceClass to the function results in the same behavior.

    To reproduce:

    let thing: Vec<PCIDevice> = PCIDevice::fetch_by_class(DeviceClass::NetworkController);
    println!("{:?}", thing);
    

    37672bea637fea077b568452ee4373b22ccba8e4 fixes this.

    bug 
    opened by grtcdr 0
  • โšก๏ธ Code Restructure & Improvements

    โšก๏ธ Code Restructure & Improvements

    What's different?

    • The linux directory now contains only one module.
    • There's unit tests now!
    • There is no longer a need to run init() after instantiating a PCIDevice
    • A PCIDevice that was fetched through instantiating the PCIDevice through PCIDevice::new() now fetches and sets the following fields: device_name, vendor_name
    • Fetchers such as fetch() and fetch_by_class() are now part of a new Fetch trait, making the structure of the library a lot nicer to work, and it makes more sense this way.

    Bonus

    • DeviceClass offers more informative documentation.
    • PATH_TO_PCI_IDS was introduced with the purpose of holding the path to the pci.ids file.

    Todo

    • [ ] ~~Address a bug which results in device_name() and class_name() returning absolutely nothing.~~

    Nope, no bugs, I was misusing the library.

    enhancement 
    opened by grtcdr 0
  • PCI ID wrong parse

    PCI ID wrong parse

    Hi,

    Thanks for for your crate. I've been testing it with mixed results as in two systems the hw listed seems ok but the other one the results are wrong. I looked at you code and found the error on the set_*_name() functions for device and subsystem.

    The parser generate not valid results due to the following bugs in your code when parsing pci id file:

    • Device name: Vendor is not considered (first step in decoding should be to locate the vendor section in the file) & the parsing do not discard '\t\t' lines that describe subystems.
    • Subsystem name: Vendor ins not considered as in the device name.

    I think these bugs are easy to fix. I can do a PR but I don't know if you are working on that as I see that you have a open PR to address accuracy.

    opened by ludiazv 1
  • test failures on ppc64le and s390x

    test failures on ppc64le and s390x

    When building aparato on ppc64le and s390x the tests fail.

    ppc64le:

        Running `/builddir/build/BUILD/aparato-6.0.0/target/release/deps/aparato-5a9ba48135f0c5e6`
    running 10 tests
    test linux::tests::test_address ... ok
    test linux::tests::test_class_id ... FAILED
    test linux::tests::test_device_id ... FAILED
    test linux::tests::test_path ... ok
    test linux::tests::test_class_name ... FAILED
    test linux::tests::test_revision ... FAILED
    test linux::tests::test_subsystem_device_id ... FAILED
    test linux::tests::test_subsystem_vendor_id ... FAILED
    test linux::tests::test_vendor_id ... FAILED
    test linux::tests::test_numa_node ... ok
    failures:
    ---- linux::tests::test_class_id stdout ----
    thread 'linux::tests::test_class_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:556:9
    ---- linux::tests::test_device_id stdout ----
    thread 'linux::tests::test_device_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:568:9
    ---- linux::tests::test_class_name stdout ----
    thread 'linux::tests::test_class_name' panicked at 'assertion failed: `(left != right)`
      left: `""`,
     right: `""`', src/linux/mod.rs:598:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    ---- linux::tests::test_revision stdout ----
    thread 'linux::tests::test_revision' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:580:9
    ---- linux::tests::test_subsystem_device_id stdout ----
    thread 'linux::tests::test_subsystem_device_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:592:9
    ---- linux::tests::test_subsystem_vendor_id stdout ----
    thread 'linux::tests::test_subsystem_vendor_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:586:9
    ---- linux::tests::test_vendor_id stdout ----
    thread 'linux::tests::test_vendor_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:562:9
    failures:
        linux::tests::test_class_id
        linux::tests::test_class_name
        linux::tests::test_device_id
        linux::tests::test_revision
        linux::tests::test_subsystem_device_id
        linux::tests::test_subsystem_vendor_id
        linux::tests::test_vendor_id
    test result: FAILED. 3 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
    

    s390x:

         Running `/builddir/build/BUILD/aparato-6.0.0/target/release/deps/aparato-dbbd6af19f4502c3`
    running 10 tests
    test linux::tests::test_address ... ok
    test linux::tests::test_class_name ... FAILED
    test linux::tests::test_device_id ... FAILED
    test linux::tests::test_numa_node ... ok
    test linux::tests::test_path ... ok
    test linux::tests::test_subsystem_device_id ... FAILED
    test linux::tests::test_revision ... FAILED
    test linux::tests::test_subsystem_vendor_id ... FAILED
    test linux::tests::test_vendor_id ... FAILED
    test linux::tests::test_class_id ... FAILED
    failures:
    ---- linux::tests::test_class_name stdout ----
    thread 'linux::tests::test_class_name' panicked at 'assertion failed: `(left != right)`
      left: `""`,
     right: `""`', src/linux/mod.rs:598:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    ---- linux::tests::test_device_id stdout ----
    thread 'linux::tests::test_device_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:568:9
    ---- linux::tests::test_subsystem_device_id stdout ----
    thread 'linux::tests::test_subsystem_device_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:592:9
    ---- linux::tests::test_revision stdout ----
    thread 'linux::tests::test_revision' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:580:9
    ---- linux::tests::test_subsystem_vendor_id stdout ----
    thread 'linux::tests::test_subsystem_vendor_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:586:9
    ---- linux::tests::test_vendor_id stdout ----
    thread 'linux::tests::test_vendor_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:562:9
    ---- linux::tests::test_class_id stdout ----
    thread 'linux::tests::test_class_id' panicked at 'assertion failed: `(left != right)`
      left: `[]`,
     right: `[]`', src/linux/mod.rs:556:9
    failures:
        linux::tests::test_class_id
        linux::tests::test_class_name
        linux::tests::test_device_id
        linux::tests::test_revision
        linux::tests::test_subsystem_device_id
        linux::tests::test_subsystem_vendor_id
        linux::tests::test_vendor_id
    test result: FAILED. 3 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
    

    You can find the full logs at https://koji.fedoraproject.org/koji/taskinfo?taskID=72224758 and https://koji.fedoraproject.org/koji/taskinfo?taskID=72224759 (look at build.log).

    bug failing-tests 
    opened by davide125 13
A library to access BGPKIT Broker API and enable searching for BGP data archive files over time from public available data sources.

BGPKIT Broker BGPKIT Broker is a online data API service that allows users to search for publicly available BGP archive files by time, collector, proj

BGPKIT 10 Nov 30, 2022
A Monte Carlo simulation of getting all possible outcomes of loot boxes opening

lootboxes_monte_carlo A monte-carlo simulation of the number of "lootboxes" to open to get at least one of each possible outcome I wondered how many l

Adssx 2 Dec 1, 2022
Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (โยดโ—ก`โ)

Sophy Bot Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (โยดโ—ก`โ) Contribution Do you like me and want to help me?

Far Dragi 0 May 30, 2022
A Garry's Mod module that lets you check which fonts are available on the system

gm_fontsx Since apparently we're never getting a proper way to check for installed fonts on Garry's Mod, this has to exist ?? Usage require("fontsx")

Earu 4 Mar 14, 2022
A publicly available implementation of knewjade's NNUE based search heuristic for HATETRIS.

A publicly available implementation of knewjade's NNUE based search heuristic for HATETRIS.

Felipe 4 Mar 13, 2023
Cross-platform GUI written in Rust using ADB to debloat non-rooted android devices

Cross-platform GUI written in Rust using ADB to debloat non-rooted android devices. Improve your privacy, the security and battery life of your device.

w1nst0n 6.8k Jan 2, 2023
Software for managing Stream Deck devices with folders and actions

Streamduck Software for managing Stream Deck devices with folders and actions Project that will perhaps be better than streamdeck-ui Currently still i

TheJebForge 21 Dec 16, 2022
use variant nesting information to flter overlapping sites from vg deconstruct output

vcfbub popping bubbles in vg deconstruct VCFs overview The VCF output produced by a command like vg deconstruct -e -a -H '#' ... includes information

null 11 Dec 28, 2022
Uradhura is a telegram bot that fetches information and media from reddit

Pathetic little Telegram bot that fetches information from Reddit posts(with gif, image(post with single image) and video)

The Penguins Org 3 May 28, 2022
A stringly-typed Error that includes `#[track_caller]` information.

A stringly-typed Error that includes #[track_caller] information.

null 5 Oct 7, 2022
Memory.lol - a tiny web service that provides historical information about social media accounts

memory.lol Overview This project is a tiny web service that provides historical information about social media accounts. It can currently be used to l

Travis Brown 317 Jul 12, 2023
Lambda function to handle Bitbucket webhook payloads, extract relevant information and send notifications to Microsoft Teams

PR-Bot Lambda function to handle Bitbucket webhook payloads, extract relevant information, and send notifications to Microsoft Teams, saving you time

Irine 14 Sep 26, 2023
Rust library that can be reset if you think it's slow

GoodbyeKT Rust library that can be reset if you think it's slow

null 39 Jun 16, 2022
Simple library to host lv2 plugins. Is not meant to support any kind of GUI.

lv2-host-minimal Simple library to host lv2 plugins. Is not meant to support any kind of GUI. Host fx plugins (audio in, audio out) Set parameters Hos

Cody Bloemhard 11 Aug 31, 2022
Extreme fast factor expression & computation library for quantitative trading in Python.

Extreme fast factor expression & computation library for quantitative trading in Python.

Weiyuan Wu 22 Dec 8, 2022
Demo for the swash font library

Demo for the swash crate See the swash repo or crate for the actual project. This is a chunk of very rough code.

Chad Brokaw 28 Nov 29, 2022
Agent library for Internet Computer, in Dart

An agent library built for Internet Computer, a plugin package for dart and flutter apps. Developers can build ones to interact with Dfinity's blockchain directly.

null 87 Dec 31, 2022
Totally Speedy Transmute (TST) is a library providing a small, performance oriented, safe version of std::mem::transmute

Totally Speedy Transmute An evil spiritual successor to Totally Safe Transmute What is it? Totally Speedy Transmute (TST) is a library providing a sma

John Schmidt 19 Jun 7, 2022
Notion Offical API client library for rust

Notion API client library for rust.

Jake Swenson 65 Dec 26, 2022