khora_core/platform/mod.rs
1// Copyright 2025 eraflo
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Provides abstractions over platform-specific functionalities.
16//!
17//! This module contains traits and types that define a common, engine-wide interface
18//! for interacting with the underlying operating system and its features, such as
19//! windowing, input, and filesystem access.
20
21pub mod window;
22
23pub use window::{KhoraWindow, KhoraWindowHandle, WindowHandle};
24
25/// Represents the thermal state of the device.
26#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
27pub enum ThermalStatus {
28 /// Device is running cool.
29 #[default]
30 Cool,
31 /// Device is warming up but within normal bounds.
32 Warm,
33 /// Device is actively throttling performance to shed heat.
34 Throttling,
35 /// Device is at critical temperature, emergency measures required.
36 Critical,
37}
38
39/// Represents the power source and battery level.
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
41pub enum BatteryLevel {
42 /// Device is connected to a stable power source.
43 #[default]
44 Mains,
45 /// Battery is high (e.g. > 50%).
46 High,
47 /// Battery is low (e.g. < 20%).
48 Low,
49 /// Battery is at critical level, power saving is mandatory.
50 Critical,
51}
52
53/// Trait for observing the physical state of the host platform.
54pub trait HardwareMonitor: Send + Sync {
55 /// Returns the current thermal status.
56 fn thermal_status(&self) -> ThermalStatus;
57 /// Returns the current battery/power level.
58 fn battery_level(&self) -> BatteryLevel;
59 /// Returns the current overall CPU load (0.0 to 1.0).
60 fn cpu_load(&self) -> f32;
61}