pci_info/error/
mod.rs

1mod pci_info_enumeration_error;
2mod pci_info_error;
3mod pci_info_error_string;
4
5use std::{error::Error, fmt::Display};
6
7pub use pci_info_enumeration_error::{
8    PciDeviceEnumerationError, PciDeviceEnumerationErrorImpact, PciDeviceEnumerationErrorLocation,
9};
10pub use pci_info_error::PciInfoError;
11pub use pci_info_error_string::PciInfoErrorString;
12
13/// An error returned when trying to access a single property of a PCI device
14#[derive(Debug)]
15pub enum PciInfoPropertyError {
16    /// The required value is not supported by the current enumerator
17    Unsupported,
18    /// The enumerator encountered an error when trying to get the value
19    /// for this property
20    Error(Box<PciInfoError>),
21}
22
23impl Display for PciInfoPropertyError {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        match self {
26            Self::Unsupported => write!(f, "unsupported by current enumerator"),
27            Self::Error(e) => write!(f, "{e}"),
28        }
29    }
30}
31
32impl Error for PciInfoPropertyError {
33    fn source(&self) -> Option<&(dyn Error + 'static)> {
34        match self {
35            Self::Unsupported => None,
36            Self::Error(e) => Some(e),
37        }
38    }
39}