feat(core): add PowerState skeleton in new power module
Introduces crates/core/src/power.rs with the PowerState enum (OnAc / OnBattery / Unknown) and a unit test confirming the three variants are distinct. Registers the module in lib.rs and adds tempfile = "3" to dev-dependencies for use in later tasks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
27
crates/core/src/power.rs
Normal file
27
crates/core/src/power.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
//! Power-state probe for inference thread tuning.
|
||||
//!
|
||||
//! Reports whether the machine is running on AC or battery so callers
|
||||
//! can drop thread counts when energy matters more than throughput.
|
||||
//! Linux uses the documented sysfs ABI under
|
||||
//! `/sys/class/power_supply/`. macOS and Windows return `Unknown` for
|
||||
//! now; native probes (IOPSGetProvidingPowerSourceType,
|
||||
//! GetSystemPowerStatus) are deferred.
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PowerState {
|
||||
OnAc,
|
||||
OnBattery,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn power_state_variants_are_distinct() {
|
||||
assert_ne!(PowerState::OnAc, PowerState::OnBattery);
|
||||
assert_ne!(PowerState::OnAc, PowerState::Unknown);
|
||||
assert_ne!(PowerState::OnBattery, PowerState::Unknown);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user