This commit is contained in:
2025-08-05 15:33:03 +02:00
parent 7856fc0a4e
commit 0c02d0e99f
326 changed files with 334 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
use sysinfo::System;
/// A struct to hold system resource information.
pub struct Resources {
/// Total memory in megabytes.
pub total_memory_mb: u64,
/// Number of CPU cores.
pub cpu_cores: usize,
}
impl Resources {
/// Detects the system's resources.
pub fn new() -> Self {
let mut sys = System::new();
sys.refresh_all();
let total_memory_mb = sys.total_memory() / 1024 / 1024;
let cpu_cores = sys.cpus().len();
Self {
total_memory_mb,
cpu_cores,
}
}
}
impl Default for Resources {
fn default() -> Self {
Self::new()
}
}