MCPcopy Create free account
hub / github.com/Autoparallel/learner / load

Method load

crates/learner/src/lib.rs:354–365  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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 ///

Callers

nothing calls this directly

Calls 2

ConfigClass · 0.85
saveMethod · 0.80

Tested by

no test coverage detected