Loads existing configuration or creates new with defaults. Looks for configuration file at the default path. If not found, creates new configuration file with default settings. # Errors Returns error if: - Configuration file exists but cannot be read - TOML parsing fails - File creation fails when saving defaults
()
| 352 | /// - TOML parsing fails |
| 353 | /// - File creation fails when saving defaults |
| 354 | pub fn load() -> Result<Self> { |
| 355 | let config_file = Self::default_path()?.join("config.toml"); |
| 356 | |
| 357 | if config_file.exists() { |
| 358 | let content = std::fs::read_to_string(&config_file)?; |
| 359 | toml::from_str(&content).map_err(|e| LearnerError::Config(e.to_string())) |
| 360 | } else { |
| 361 | let config = Self::default(); |
| 362 | config.save()?; |
| 363 | Ok(config) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | /// Saves current configuration to disk. |
| 368 | /// |