sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
use super::System;
use crate::{Error, LoadAvg, SystemInner};

impl System {
    /// Returns the system uptime in seconds.
    pub fn uptime() -> Result<u64, Error> {
        SystemInner::uptime()
    }

    /// Returns the time the system booted, in seconds since the UNIX epoch.
    pub fn boot_time() -> Result<u64, Error> {
        SystemInner::boot_time()
    }

    /// Returns the system load average.
    pub fn load_average() -> Result<LoadAvg, Error> {
        SystemInner::load_average()
    }

    /// Returns the system name.
    pub fn name() -> Result<String, Error> {
        SystemInner::name()
    }

    /// Returns the kernel version.
    pub fn kernel_version() -> Result<String, Error> {
        SystemInner::kernel_version()
    }

    /// Returns the OS version.
    pub fn os_version() -> Result<String, Error> {
        SystemInner::os_version()
    }

    /// Returns the long OS version.
    pub fn long_os_version() -> Result<String, Error> {
        SystemInner::long_os_version()
    }

    /// Returns the distribution ID defined by os-release, or [`std::env::consts::OS`].
    pub fn distribution_id() -> String {
        SystemInner::distribution_id()
    }

    /// Returns the distribution IDs of operating systems closely related to the local one with respect to packaging and programming interfaces.
    pub fn distribution_id_like() -> Vec<String> {
        SystemInner::distribution_id_like()
    }

    /// Returns the kernel name and version formatted as a single string.
    pub fn kernel_long_version() -> Result<String, Error> {
        let Some(kernel_name) = SystemInner::kernel_name() else {
            return Err(Error::Unsupported);
        };
        let kernel_version = System::kernel_version();
        let kernel_version = kernel_version.as_deref().unwrap_or("Unknown");
        Ok(if cfg!(windows) {
            format!("{kernel_name} OS Build {kernel_version}")
        } else {
            format!("{kernel_name} {kernel_version}")
        })
    }

    /// Returns the system hostname, resolved via DNS.
    pub fn host_name() -> Result<String, Error> {
        SystemInner::host_name()
    }

    /// Returns the CPU architecture (for example, x86, amd64, or aarch64).
    pub fn cpu_arch() -> String {
        SystemInner::cpu_arch().unwrap_or_else(|| std::env::consts::ARCH.to_owned())
    }

    /// Returns the number of physical CPU cores.
    pub fn physical_core_count() -> Result<usize, Error> {
        SystemInner::physical_core_count()
    }

    /// Returns the default maximum number of open files for a process.
    pub fn open_files_limit() -> Result<usize, Error> {
        SystemInner::open_files_limit()
    }
}