use std::fs; use std::path::Path; use serde::{Deserialize, Serialize}; use url::Url; use crate::error::ConfigError; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct Config { pub registry_url: Url, } impl Default for Config { fn default() -> Self { Self { registry_url: Url::parse("https://localhost:5000").unwrap(), } } } impl TryFrom<&Path> for Config { type Error = ConfigError; fn try_from(path: &Path) -> Result { let contents = fs::read_to_string(path)?; let config: Self = toml::from_str(&contents)?; Ok(config) } }