-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also bumped version # and added build # to build workflow.
- Loading branch information
1 parent
cde1ae4
commit 2161ef8
Showing
6 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mod processor; | ||
pub mod windows { | ||
use super::processor; | ||
|
||
#[derive(Debug)] | ||
pub struct HardwareInfo { | ||
processor_info: processor::windows::ProcessorInfo, | ||
} | ||
|
||
pub fn get_hardware_info() -> Result<HardwareInfo, windows::core::Error> { | ||
Ok( | ||
HardwareInfo { | ||
processor_info: processor::windows::get_processor_info()?, | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
pub mod windows { | ||
use crate::utils::windows::get_wmi; | ||
|
||
#[derive(Debug)] | ||
pub struct ProcessorInfo { | ||
name: String, | ||
cores: u32, | ||
threads: u32, | ||
current_clock_speed: u32, | ||
current_voltage: Option<u16>, | ||
max_clock_speed: u32, | ||
processor_socket: String, | ||
load_percentage: u16, | ||
voltage_caps: Option<String>, | ||
} | ||
|
||
pub fn get_processor_info() -> Result<ProcessorInfo, windows::core::Error> { | ||
let processor_info = get_wmi("Win32_Processor", "Name, NumberOfCores, ThreadCount, CurrentClockSpeed, CurrentVoltage, MaxClockSpeed, SocketDesignation, LoadPercentage, VoltageCaps")?; | ||
|
||
Ok( | ||
ProcessorInfo { | ||
name: processor_info.get("Name").unwrap().to_string(), | ||
cores: processor_info.get("NumberOfCores").unwrap().to_string().parse().unwrap(), | ||
threads: processor_info.get("ThreadCount").unwrap().to_string().parse().unwrap(), | ||
current_clock_speed: processor_info.get("CurrentClockSpeed").unwrap().to_string().parse().unwrap(), | ||
current_voltage: { | ||
let value:u16 = processor_info.get("CurrentVoltage").unwrap().parse().unwrap(); | ||
if (value & 0x0080) != 0 { | ||
Some((value & 0x7f) * 10) | ||
} else { | ||
None | ||
} | ||
}, | ||
max_clock_speed: processor_info.get("MaxClockSpeed").unwrap().to_string().parse().unwrap(), | ||
processor_socket: processor_info.get("SocketDesignation").unwrap().to_string(), | ||
load_percentage: processor_info.get("LoadPercentage").unwrap().to_string().parse().unwrap(), | ||
voltage_caps: match processor_info.get("VoltageCaps").unwrap().as_str() { | ||
"" => None, | ||
value => Some(value.to_string()), | ||
}, | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters