use crate::settings::Settings;
mod filesystem;
mod inmem;
use std::path::{Path, PathBuf};
pub use filesystem::FileSystem;
pub use inmem::Inmem;
#[cfg(test)]
use mockall::{automock, predicate::*};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("{0}")]
Message(String),
#[error(transparent)]
TemplateEngine(#[from] Box<rhai::EvalAltResult>),
#[error(transparent)]
FS(#[from] fs_extra::error::Error),
#[error(transparent)]
Template(#[from] tera::Error),
}
impl Error {
pub fn msg<S: Into<String>>(msg: S) -> Self {
Self::Message(msg.into())
}
}
#[cfg_attr(test, automock)]
pub trait Executer: Send + Sync {
fn copy_file(&self, path: &Path) -> Result<PathBuf>;
fn create_file(&self, path: &Path, content: String) -> Result<PathBuf>;
fn copy_dir(&self, path: &Path) -> Result<()>;
fn copy_template(&self, path: &Path, data: &Settings) -> Result<()>;
fn copy_template_dir(&self, path: &Path, data: &Settings) -> Result<()>;
}