mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-10-28 16:30:48 +08:00
feat: 初步增加 Windows 支持
This commit is contained in:
47
src/diagnostics/mod.rs
Normal file
47
src/diagnostics/mod.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! Host diagnostics used by the web status API.
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::error::Result;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeviceInfo {
|
||||
pub hostname: String,
|
||||
pub cpu_model: String,
|
||||
pub cpu_usage: f32,
|
||||
pub memory_total: u64,
|
||||
pub memory_used: u64,
|
||||
pub network_addresses: Vec<NetworkAddress>,
|
||||
pub serial_ports: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct NetworkAddress {
|
||||
pub interface: String,
|
||||
pub ip: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DiskSpaceInfo {
|
||||
pub total: u64,
|
||||
pub available: u64,
|
||||
pub used: u64,
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod linux;
|
||||
#[cfg(windows)]
|
||||
mod windows;
|
||||
|
||||
#[cfg(unix)]
|
||||
use linux as platform;
|
||||
#[cfg(windows)]
|
||||
use windows as platform;
|
||||
|
||||
pub fn get_disk_space(path: &std::path::Path) -> Result<DiskSpaceInfo> {
|
||||
platform::get_disk_space(path)
|
||||
}
|
||||
|
||||
pub fn get_device_info() -> DeviceInfo {
|
||||
platform::get_device_info()
|
||||
}
|
||||
Reference in New Issue
Block a user