sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
use std::{error, fmt, io};

/// Error type for the main failures that can occur while querying system information.
#[derive(Debug)]
pub enum Error {
    /// The feature is not supported on this platform.
    Unsupported,
    /// An I/O error occurred while querying the information.
    Io(io::Error),
    /// Any non-I/O error on supported platforms.
    Other(Box<dyn error::Error + Send + Sync + 'static>),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::Unsupported => f.write_str("unsupported"),
            Error::Io(e) => fmt::Display::fmt(e, f),
            Error::Other(e) => fmt::Display::fmt(e, f),
        }
    }
}

impl error::Error for Error {
    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
        match self {
            Error::Io(e) => Some(e),
            Error::Other(e) => Some(&**e),
            _ => None,
        }
    }
}

impl From<io::Error> for Error {
    fn from(e: io::Error) -> Self {
        Error::Io(e)
    }
}

impl From<&'static str> for Error {
    fn from(e: &'static str) -> Self {
        Error::Other(e.into())
    }
}