Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to list connected gpu(s) #140

Merged
merged 8 commits into from
Mar 20, 2023
4 changes: 1 addition & 3 deletions src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,8 @@ impl GeneralReadout for LinuxGeneralReadout {
fn disk_space(&self) -> Result<(u128, u128), ReadoutError> {
shared::disk_space(String::from("/"))
}
}

impl LinuxGeneralReadout {
pub fn list_gpus(&self) -> Result<Vec<String>, ReadoutError> {
fn list_gpus(&self) -> Result<Vec<String>, ReadoutError> {
let db = match Database::read() {
Ok(db) => db,
_ => panic!("Could not read pci.ids file"),
Expand Down
8 changes: 8 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,11 @@ impl GeneralReadout for MacOSGeneralReadout {
fn disk_space(&self) -> Result<(u128, u128), ReadoutError> {
Ok((50000000,1000000000)) // Used / Total
}

fn list_gpus(&self) -> Result<Vec<String>, ReadoutError> {
// Get gpu(s) from list of connected pci devices
Ok(vec!(String::from("gpu1"), String::from("gpu2"))) // Return gpu sub-device names
}
}

```
Expand Down Expand Up @@ -581,6 +586,9 @@ pub trait GeneralReadout {
///
/// _e.g._ '1.2TB / 2TB'
fn disk_space(&self) -> Result<(u128, u128), ReadoutError>;

/// This function should return the sub device names of any _GPU(s)_ connected to the host machine.
fn list_gpus(&self) -> Result<Vec<String>, ReadoutError>;
Rolv-Apneseth marked this conversation as resolved.
Show resolved Hide resolved
}

/// Holds the possible variants for battery status.
Expand Down