use serde::{Deserialize, Serialize}; use std::{ collections::HashMap, fs::File, io::{Error, ErrorKind, Read}, path::PathBuf, }; use toml::from_str; #[derive(Serialize, Deserialize)] pub struct Config { pub workspace_directory: String, pub max_depth: usize, pub project_marker: Vec, pub directories: HashMap, } #[derive(Serialize, Deserialize)] struct DirectoryConfig { pub priority: u32, pub icon: String, } impl Config { pub fn load(path: PathBuf) -> Result { let mut file = File::open(path)?; let mut contents = String::new(); file.read_to_string(&mut contents)?; from_str(&contents).map_err(|e| Error::new(ErrorKind::InvalidData, e)) } }