use super::RuntimeError; use crate::{Build, FileSystemTree, MergeableFileSystemTree, Node}; use pipe_trait::Pipe; use serde::de::DeserializeOwned; use serde_yaml::from_reader; use std::{ io, path::{Path, PathBuf}, }; /// Read a YAML from stdin and build a filesystem tree. pub fn run(target: &Path) -> Result<(), RuntimeError> where Path: ToOwned + AsRef + ?Sized, Path::Owned: AsRef, Tree: Build + Node + DeserializeOwned, Tree::DirectoryContent: IntoIterator, Path: Ord, { io::stdin() .pipe(from_reader::<_, Tree>)? .build(target)? .pipe(Ok) } /// Read a YAML from stdin and build a filesystem tree. pub type Run = fn(&Path) -> Result<(), RuntimeError>; /// Read a YAML from stdin and create a new filesystem tree. pub const CREATE: Run = run::, Path>; /// Read a YAML from stdin and populate the target filesystem tree. pub const POPULATE: Run = run::, Path>;