//! Configuration loading and parsing logic.

use std::path::Path;

use crate::AphoriaError;

use super::types::AphoriaConfig;

impl AphoriaConfig {
    /// Load configuration from a TOML file.
    pub fn from_file(path: &Path) -> Result<Self, AphoriaError> {
        if !path.exists() {
            return Err(AphoriaError::ConfigNotFound(path.to_path_buf()));
        }

        let content = std::fs::read_to_string(path)?;
        let config: AphoriaConfig = toml::from_str(&content)?;
        Ok(config)
    }
}
