use config::{Config, ConfigError, File}; use std::path::PathBuf; #[derive(Debug, Deserialize, Clone)] pub enum WorldType { END, NETHER, OVERWORLD, } impl From for WorldType { fn from(string: String) -> Self { match string.as_str() { "END" => WorldType::END, "NETHER" => WorldType::NETHER, _ => WorldType::OVERWORLD, } } } #[derive(Debug, Deserialize, Clone)] pub struct WorldConfig { pub world_name: String, pub save_radius: u64, pub world_type: Option, } #[derive(Debug, Deserialize, Clone)] pub struct BackupConfig { pub minecraft_dir: PathBuf, pub output_dir: PathBuf, pub backups_to_keep: u64, } #[derive(Debug, Deserialize, Clone)] pub struct AlbatrossConfig { pub backup: BackupConfig, pub world_config: Option>, } impl AlbatrossConfig { pub fn new(config_path: &str) -> Result { let mut cfg = Config::new(); cfg.merge(File::with_name(config_path))?; cfg.try_into() } }