fix: corriger les erreurs de compilation (Default, Debug, rustls)

This commit is contained in:
2026-06-22 16:47:02 -04:00
parent a3b853de04
commit 38f274c3d5
6 changed files with 3539 additions and 65 deletions
+69 -39
View File
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;
/// Configuration complète d'imagod-web
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Config {
#[serde(default)]
pub imago: ImagoConfig,
@@ -19,72 +19,105 @@ pub struct Config {
pub logging: LoggingConfig,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ImagoConfig {
#[serde(default = "default_imago_url")]
pub url: String,
#[serde(default)]
pub api_key: String,
}
fn default_imago_url() -> String {
"http://imago.dracodev.net:8000".into()
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WatcherConfig {
#[serde(default = "default_true")]
pub capture_images: bool,
#[serde(default = "default_poll_interval")]
pub poll_interval_ms: u64,
#[serde(default)]
pub filters: WatcherFilters,
}
impl Default for WatcherConfig {
fn default() -> Self {
Self {
capture_images: true,
poll_interval_ms: 500,
filters: WatcherFilters::default(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WatcherFilters {
#[serde(default)]
pub only_apps: Vec<String>,
#[serde(default = "default_exclude_apps")]
pub exclude_apps: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
impl Default for WatcherFilters {
fn default() -> Self {
Self {
only_apps: vec![],
exclude_apps: vec!["mstsc".into()],
}
}
}
fn default_exclude_apps() -> Vec<String> {
vec!["mstsc".into()]
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DedupConfig {
#[serde(default = "default_dedup_method")]
pub method: String,
#[serde(default = "default_cache_size")]
pub cache_size: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
fn default_dedup_method() -> String {
"sha256".into()
}
fn default_cache_size() -> usize {
10000
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct UiConfig {
#[serde(default = "default_true")]
pub show_notifications: bool,
#[serde(default = "default_true")]
pub show_tray_icon: bool,
#[serde(default = "default_notification_timeout")]
pub notification_timeout_sec: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
fn default_notification_timeout() -> u64 {
3
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct LoggingConfig {
#[serde(default = "default_log_level")]
pub level: String,
}
impl Default for Config {
fn default() -> Self {
Self {
imago: ImagoConfig {
url: "http://imago.dracodev.net:8000".into(),
api_key: String::new(),
},
watcher: WatcherConfig {
capture_images: true,
poll_interval_ms: 500,
filters: WatcherFilters {
only_apps: vec![],
exclude_apps: vec!["mstsc".into()],
},
},
dedup: DedupConfig {
method: "sha256".into(),
cache_size: 10000,
},
ui: UiConfig {
show_notifications: true,
show_tray_icon: true,
notification_timeout_sec: 3,
},
logging: LoggingConfig {
level: "info".into(),
},
}
}
fn default_log_level() -> String {
"info".into()
}
fn default_true() -> bool {
true
}
fn default_poll_interval() -> u64 {
500
}
impl Config {
@@ -98,7 +131,6 @@ impl Config {
.with_context(|| "Erreur de parsing du fichier de configuration")?;
Ok(config)
} else {
// Premier lancement — créer la config par défaut
let config = Config::default();
config.save()?;
Ok(config)
@@ -119,12 +151,10 @@ impl Config {
/// Chemin du fichier de configuration
fn config_path() -> Result<PathBuf> {
let base = if cfg!(target_os = "windows") {
let appdata = std::env::var("APPDATA")
.context("Variable APPDATA non définie")?;
let appdata = std::env::var("APPDATA").context("Variable APPDATA non définie")?;
PathBuf::from(appdata)
} else {
let home = std::env::var("HOME")
.context("Variable HOME non définie")?;
let home = std::env::var("HOME").context("Variable HOME non définie")?;
PathBuf::from(home).join(".config")
};
Ok(base.join("imagod-web").join("imagod.toml"))