peace_resource_rt 0.0.15

Runtime resources for the peace automation framework.
Documentation
use std::{fmt, path::PathBuf};

use crate::paths::PeaceAppDir;

/// Path to the file that stores the workspace initialization parameters.
///
/// Typically `$workspace_dir/.peace/$app/workspace_params.yaml`.
///
/// See `WorkspaceParamsFile::from<&PeaceAppDir>` if you want to construct a
/// `WorkspaceParamsFile` with the conventional
/// `$peace_dir/$app/workspace_params.yaml` path.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WorkspaceParamsFile(PathBuf);

crate::paths::pathbuf_newtype!(WorkspaceParamsFile);

impl WorkspaceParamsFile {
    /// File name of the workspace parameters file.
    pub const NAME: &'static str = "workspace_params.yaml";
}

impl From<&PeaceAppDir> for WorkspaceParamsFile {
    fn from(flow_dir: &PeaceAppDir) -> Self {
        let path = flow_dir.join(Self::NAME);

        Self(path)
    }
}

impl fmt::Display for WorkspaceParamsFile {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.0.display())
    }
}