use crate::{PciInfo, PciInfoError};
#[cfg(target_os = "linux")]
mod proc_fs;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum LinuxProcFsPciEnumerator {
Fastest,
HeadersOnly,
SkipNoncommonHeaders,
Exhaustive,
}
impl crate::PciEnumerator for LinuxProcFsPciEnumerator {
fn enumerate_pci(self) -> Result<PciInfo, PciInfoError> {
let (read_headers, read_extended_headers, read_device_file) = match self {
Self::Fastest => (false, false, true),
Self::HeadersOnly => (true, true, false),
Self::SkipNoncommonHeaders => (true, false, true),
Self::Exhaustive => (true, true, true),
};
#[cfg(target_os = "linux")]
proc_fs::enumerate_pci(read_headers, read_extended_headers, read_device_file)
}
}
test_enumerator!(
LinuxProcFsPciEnumeratorFastest,
LinuxProcFsPciEnumerator::Fastest
);
test_enumerator!(
LinuxProcFsPciEnumeratorExhaustive,
LinuxProcFsPciEnumerator::Exhaustive
);
test_enumerator!(
LinuxProcFsPciEnumeratorHeadersOnly,
LinuxProcFsPciEnumerator::HeadersOnly
);
test_enumerator!(
LinuxProcFsPciEnumeratorSkipNoncommonHeaders,
LinuxProcFsPciEnumerator::SkipNoncommonHeaders
);