feat(agent): setup Cargo.toml et structure complète
Initialise la structure de l'agent Rust avec tous les modules stub : config, payload, metrics (cpu/memory/disk/network/uptime/temperature/smart), transport (udp/mqtt). Corrige les features sysinfo 0.30 (pas de feature disk/networks séparées). Compile sans erreurs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
395e006014
commit
3f5c735507
@@ -0,0 +1,81 @@
|
||||
// stub — implémenté dans la Task 2
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct Config {
|
||||
pub server: ServerConfig,
|
||||
pub protocols: ProtocolsConfig,
|
||||
#[serde(default)]
|
||||
pub metrics: MetricsConfig,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct ServerConfig {
|
||||
pub ip: String,
|
||||
pub port: u16,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct ProtocolsConfig {
|
||||
#[serde(default)]
|
||||
pub udp: UdpConfig,
|
||||
#[serde(default)]
|
||||
pub mqtt: MqttConfig,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct UdpConfig {
|
||||
#[serde(default)]
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct MqttConfig {
|
||||
#[serde(default)]
|
||||
pub enabled: bool,
|
||||
#[serde(default)]
|
||||
pub host: String,
|
||||
#[serde(default)]
|
||||
pub port: u16,
|
||||
#[serde(default)]
|
||||
pub topic_base: String,
|
||||
#[serde(default)]
|
||||
pub auto_discovery: bool,
|
||||
#[serde(default)]
|
||||
pub birth_message: bool,
|
||||
#[serde(default)]
|
||||
pub last_will: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct MetricsConfig {
|
||||
#[serde(default)]
|
||||
pub cpu: MetricProto,
|
||||
#[serde(default)]
|
||||
pub memory: MetricProto,
|
||||
#[serde(default)]
|
||||
pub disk: MetricProto,
|
||||
#[serde(default)]
|
||||
pub network: MetricProto,
|
||||
#[serde(default)]
|
||||
pub uptime: MetricProto,
|
||||
#[serde(default)]
|
||||
pub temperature: MetricProto,
|
||||
#[serde(default)]
|
||||
pub smart: MetricProto,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Default)]
|
||||
pub struct MetricProto {
|
||||
#[serde(default)]
|
||||
pub udp: bool,
|
||||
#[serde(default)]
|
||||
pub mqtt: bool,
|
||||
}
|
||||
|
||||
pub fn load(path: &Path) -> Result<Config, Box<dyn std::error::Error>> {
|
||||
let content = std::fs::read_to_string(path)?;
|
||||
let config: Config = toml::from_str(&content)?;
|
||||
Ok(config)
|
||||
}
|
||||
Reference in New Issue
Block a user