use serde::Deserialize; use std::path::Path; #[derive(Debug, Clone, Deserialize)] pub struct SyncConfig { /// Base URL of the local CAN service (e.g. "http://127.0.0.1:3210") pub can_service_url: String, /// API key for CAN service's sync endpoints (must match config.sync_api_key) pub sync_api_key: String, /// Shared passphrase for peer discovery (all peers must use the same one) pub sync_passphrase: String, /// Seconds between polls for new local assets #[serde(default = "default_poll_interval")] pub poll_interval_secs: u64, /// Optional: path to write this node's ticket to (for direct connection) #[serde(default)] pub ticket_file: Option, /// Optional: path to a file containing a peer's node ticket (for direct connection). /// If set, the agent will read this ticket and connect directly instead of waiting /// for gossip discovery. The file is polled until it exists and is non-empty. #[serde(default)] pub connect_ticket_file: Option, } fn default_poll_interval() -> u64 { 3 } impl SyncConfig { pub fn load(path: &Path) -> anyhow::Result { let contents = std::fs::read_to_string(path)?; let config: Self = serde_yaml::from_str(&contents)?; Ok(config) } }