| Crates.io | ids_rs |
| lib.rs | ids_rs |
| version | 0.1.0 |
| created_at | 2025-10-13 16:28:38.352824+00 |
| updated_at | 2025-10-13 16:28:38.352824+00 |
| description | A no_std PCI device identification library for operating systems |
| homepage | |
| repository | https://github.com/your-username/ids_rs |
| max_upload_size | |
| id | 1880753 |
| size | 1,708,735 |
A no_std-compatible PCI device identification library designed specifically for operating systems and low-level system software. This crate parses the PCI IDs database at compile time, enabling efficient runtime lookups without heap allocation or file I/O.
Add this to your Cargo.toml:
[dependencies]
ids_rs = "0.1"
use ids_rs::{PciDatabase, VendorId, DeviceId, DeviceClassId, SubClassId};
// Get the compiled database
let db = PciDatabase::get();
// Look up a vendor (Intel)
let vendor_id = VendorId::new(0x8086);
if let Some(vendor) = db.find_vendor(vendor_id) {
println!("Vendor: {}", vendor.name());
}
// Look up a specific device
let device_id = DeviceId::new(0x1234);
if let Some(device) = db.find_device(vendor_id, device_id) {
println!("Device: {}", device.name());
}
// Get a complete device description
let description = db.describe_device(
vendor_id,
device_id,
Some(DeviceClassId::new(0x02)), // Network controller
Some(SubClassId::new(0x00)), // Ethernet controller
None,
None,
None,
);
println!("Full description: {}", description);
use ids_rs::{PciDatabase, QueryBuilder};
let db = PciDatabase::get();
// Find all Intel network devices
let intel_network_devices = db.query()
.vendor_name_contains("Intel")
.class_name_contains("Network")
.execute();
for device_match in intel_network_devices {
println!("{}: {}", device_match.vendor_name(), device_match.device_name());
}
// Search for specific device types
let ethernet_devices = db.search_devices("ethernet");
let wireless_classes = db.search_classes("wireless");
use ids_rs::{PciDatabase, DeviceClassId, SubClassId, ProgInterfaceId};
let db = PciDatabase::get();
// Look up device class information
let class_id = DeviceClassId::new(0x0c); // Serial bus controller
let subclass_id = SubClassId::new(0x03); // USB controller
let prog_if_id = ProgInterfaceId::new(0x30); // XHCI
if let Some(prog_if) = db.find_prog_interface(class_id, subclass_id, prog_if_id) {
println!("Programming interface: {}", prog_if.name());
}
The crate includes scripts to download and update the PCI IDs database:
.\update_pci_ids.ps1
./update_pci_ids.sh
These scripts will:
-Force to override)After updating the database, rebuild your project to incorporate the new data:
cargo clean
cargo build
The crate is organized into focused modules:
types: Type-safe wrappers for PCI identifiersvendors: Vendor definitions and utilitiesdevices: Device and subsystem definitionsclasses: Device class, subclass, and programming interface definitionsdatabase: Main database interface and lookupsquery: Advanced query builder and search functionalityparser: PCI IDs format parser (build-time only)error: Error types and handlingThe PCI IDs database is parsed at compile time using a build script. This approach provides:
The generated database uses efficient memory layouts:
&'static str referencesThis crate is fully compatible with no_std environments:
#![no_std]
use ids_rs::{PciDatabase, VendorId};
fn main() {
// Works in no_std environments
let db = PciDatabase::get();
let vendor = db.find_vendor(VendorId::new(0x8086));
}
The only requirement is the heapless crate for some string operations in type conversion methods.
VendorId, DeviceId: Type-safe PCI vendor and device identifiersSubvendorId, SubdeviceId: Type-safe subsystem identifiersDeviceClassId, SubClassId, ProgInterfaceId: Type-safe class identifiersPciDatabase: Main database interfaceVendor: PCI vendor informationDevice: PCI device informationSubsystem: PCI subsystem informationDeviceClass: PCI device class informationQueryBuilder: Flexible query builder for complex searchesDeviceMatch: Device search resultClassMatch: Class search resultThe library is designed for maximum performance in system-level code:
This library is ideal for:
The current PCI IDs database contains approximately:
Contributions are welcome! Please:
no_std compatibilityMIT