Files
watcheragent/WatcherAgent/src/models.rs

101 lines
2.5 KiB
Rust

use serde::{Deserialize, Serialize};
// Data structures matching the C# DTOs
#[derive(Serialize, Debug)]
pub struct RegistrationDto {
#[serde(rename = "id")]
pub id: i32,
#[serde(rename = "ipAddress")]
pub ip_address: String,
#[serde(rename = "cpuType")]
pub cpu_type: String,
#[serde(rename = "cpuCores")]
pub cpu_cores: i32,
#[serde(rename = "gpuType")]
pub gpu_type: String,
#[serde(rename = "ramSize")]
pub ram_size: f64,
}
#[derive(Serialize, Debug)]
pub struct MetricDto {
#[serde(rename = "serverId")]
pub server_id: i32,
#[serde(rename = "ipAddress")]
pub ip_address: String,
#[serde(rename = "cpu_Load")]
pub cpu_load: f64,
#[serde(rename = "cpu_Temp")]
pub cpu_temp: f64,
#[serde(rename = "gpu_Load")]
pub gpu_load: f64,
#[serde(rename = "gpu_Temp")]
pub gpu_temp: f64,
#[serde(rename = "gpu_Vram_Size")]
pub gpu_vram_size: f64,
#[serde(rename = "gpu_Vram_Usage")]
pub gpu_vram_usage: f64,
#[serde(rename = "ram_Load")]
pub ram_load: f64,
#[serde(rename = "ram_Size")]
pub ram_size: f64,
#[serde(rename = "disk_Size")]
pub disk_size: f64,
#[serde(rename = "disk_Usage")]
pub disk_usage: f64,
#[serde(rename = "disk_Temp")]
pub disk_temp: f64,
#[serde(rename = "net_In")]
pub net_rx: f64,
#[serde(rename = "net_Out")]
pub net_tx: f64,
}
#[derive(Serialize, Debug)]
pub struct DiskInfoDetailed {
pub disk_name: String,
pub disk_kind: String,
pub disk_total_space: f64,
pub disk_available_space: f64,
pub disk_used_space: f64,
pub disk_mount_point: String,
pub component_disk_label: String,
pub component_disk_temperature: f32,
}
#[derive(Deserialize)]
pub struct IdResponse {
pub id: i32,
#[serde(rename = "ipAddress")]
pub ip_address: String,
}
#[derive(Serialize)]
pub struct HeartbeatDto {
#[serde(rename = "IpAddress")]
pub ip_address: String,
}
#[derive(Serialize, Debug)]
pub struct HardwareDto {
pub cpu_type: String,
pub cpu_cores: i32,
pub gpu_type: String,
pub ram_size: f64,
pub ip_address: String,
}
#[derive(Debug, Deserialize, Clone)]
pub struct ServerMessage {
// Define your message structure here
pub message_type: String,
pub data: serde_json::Value,
pub message_id: String, // Add an ID for acknowledgment
}
#[derive(Debug, Serialize, Clone)]
pub struct Acknowledgment {
pub message_id: String,
pub status: String, // "success" or "error"
pub details: String,
}