Skip to main content

normalize_pci_id

Function normalize_pci_id 

Source
pub fn normalize_pci_id(id: &str) -> Option<String>
Expand description

Normalize a PCI address (domain:bus:dev.func) for cross-backend dedupe: NVML reports 00000000:01:00.0 while sysfs and D3DKMT-derived ids report 0000:01:00.0 — the same physical GPU. Lowercase everything; trim/zero-pad the domain to 4 hex digits (a genuinely >16-bit domain keeps its extra digits — all sources print those the same way). Returns None for anything that isn’t a PCI address (mock:…, wddm:…, apple:…, nvml:0 fallback ids) — those are never deduped: wrongly merging two distinct devices is worse than listing one twice.

Lives in core (moved from the tui collector per design cross-platform.md §5.4) so the collector’s dedupe and the Windows backends’ LUID↔PCI matching share one rule.