genotype_project 0.16.0

Genotype language project crate
Documentation
use crate::prelude::internal::*;

impl GtpConfig {
    pub fn save(&self, path: &GtpCwdRelativeOrAbsoluteStringPath) -> Result<()> {
        let path: GtpCwdRelativePath = path.try_into()?;
        let path = path.to_path_buf();
        let file = if path.is_dir() {
            unimplemented!()
            // match Self::find(path) {
            //     Ok(file) => file,
            //     Err(_) => path.join(GTCONFIG_FILE),
            // }
        } else if path.ends_with(GTCONFIG_FILE) {
            path.to_path_buf()
        } else {
            unimplemented!()
            // Self::find(path)?
        };

        fs::write(&file, self.to_toml_str_pruned()?)
            .map_err(|_| GtpConfigError::FailedSaveConfig(file.display().to_string()))
            .into_diagnostic()?;

        Ok(())
    }
}