use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Config { #[serde(default)] pub gate_open: bool, #[serde(default = "default_supported_platforms")] pub supported_platforms: Vec, } impl Default for Config { fn default() -> Self { Self { gate_open: false, supported_platforms: default_supported_platforms() } } } impl Config { pub fn supports_platform(&self, platform: &String) -> bool { self.supported_platforms.contains(platform) } } fn default_supported_platforms() -> Vec { vec!["win32".to_string()] } pub fn get_config() -> Config { if let Ok(data) = std::fs::read_to_string("config.json") { serde_json::from_str(&data).expect("Failed to parse") } else { Config::default() } }