use sysinfo::System; use crate::types::Megabytes; /// Detected system capabilities. #[derive(Debug, Clone)] pub struct SystemProfile { pub ram: Megabytes, pub cpu: CpuInfo, pub gpu: Option, pub os: Os, } #[derive(Debug, Clone)] pub struct CpuInfo { pub logical_processors: usize, pub brand: String, } #[derive(Debug, Clone)] pub struct GpuInfo { pub vendor: GpuVendor, pub vram: Megabytes, pub acceleration: GpuAcceleration, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum GpuVendor { Nvidia, Amd, Intel, Apple, Unknown, } #[derive(Debug, Clone)] pub struct GpuAcceleration { pub cuda: bool, pub metal: bool, pub vulkan: bool, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Os { Windows, Linux, MacOs, Ios, Android, } /// Probes RAM from a shared `System` instance. fn probe_ram_from(sys: &System) -> Megabytes { let total_bytes = sys.total_memory(); Megabytes(total_bytes / (1024 * 1024)) } /// Probes CPU info from a shared `System` instance. fn probe_cpu_from(sys: &System) -> CpuInfo { CpuInfo { logical_processors: sys.cpus().len(), brand: sys .cpus() .first() .map(|c| c.brand().to_string()) .unwrap_or_default(), } } pub fn probe_gpu() -> Option { // GPU detection via wgpu or platform-specific APIs. // Placeholder: returns None until wgpu or nvml integration is added. None } pub fn probe_os() -> Os { #[cfg(target_os = "windows")] return Os::Windows; #[cfg(target_os = "linux")] return Os::Linux; #[cfg(target_os = "macos")] return Os::MacOs; #[cfg(target_os = "ios")] return Os::Ios; #[cfg(target_os = "android")] return Os::Android; // Fallback for unsupported targets — treat as Linux since // most exotic/embedded targets are Unix-like. #[allow(unreachable_code)] Os::Linux } /// Composes the individual probes using a single `System` snapshot. /// `System::new_all()` is expensive — calling it once rather than /// per-probe avoids redundant OS queries. pub fn probe_system() -> SystemProfile { let sys = System::new_all(); SystemProfile { ram: probe_ram_from(&sys), cpu: probe_cpu_from(&sys), gpu: probe_gpu(), os: probe_os(), } }