sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
use std::cmp::Ordering;

use crate::{GpuInner, PCI};

/// Information about a single GPU.
pub struct Gpu {
    pub(crate) inner: GpuInner,
}

impl PartialEq for Gpu {
    fn eq(&self, other: &Self) -> bool {
        self.pci() == other.pci()
    }
}

impl Eq for Gpu {}

impl PartialOrd for Gpu {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for Gpu {
    fn cmp(&self, other: &Self) -> Ordering {
        self.pci().cmp(other.pci())
    }
}

impl Gpu {
    /// Returns the PCI address of this GPU.
    pub fn pci(&self) -> &PCI {
        self.inner.pci()
    }

    /// Returns the GPU vendor name.
    pub fn vendor(&self) -> Option<&str> {
        self.inner.vendor()
    }

    /// Returns the GPU model.
    pub fn model(&self) -> Option<&str> {
        self.inner.model()
    }

    /// Returns the usage of this GPU as a percentage.
    pub fn usage(&self) -> Option<f32> {
        self.inner.usage()
    }

    /// Returns the total VRAM of this GPU in bytes.
    pub fn total_memory(&self) -> Option<u64> {
        self.inner.total_memory()
    }

    /// Returns the used VRAM of this GPU in bytes.
    pub fn used_memory(&self) -> Option<u64> {
        self.inner.used_memory()
    }
}