1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
use std::path::PathBuf;
use getset::{Getters, Setters};
use super::{artifact_assets::ArtifactAssets, Artifact, ArtifactError};
/// Final compilation result
#[derive(Debug, Getters, Setters)]
pub struct ArtifactsCollection {
#[getset(get = "pub", set = "pub")]
assets: Option<ArtifactAssets>,
#[getset(get = "pub", set = "pub")]
artifacts: Vec<Artifact>,
#[getset(get = "pub", set = "pub")]
output_path: PathBuf
}
#[allow(dead_code)]
impl ArtifactsCollection {
pub fn new(output_path: PathBuf) -> Result<Self, ArtifactError> {
if !output_path.is_dir() {
return Err(ArtifactError::OutputPathNotDir)
}
Ok(Self {
assets: Option::None,
artifacts: Vec::new(),
output_path
})
}
// TODO
// pub fn add_artifact(&mut self, document_name: &String, document_content: &String) -> Result<(), ArtifactError> {
// let final_location = self.output_path.join(document_name);
// let mut document = CachedDiskResource::try_from(final_location)?;
// document.set_cached_content(document_content);
// self.artifacts.push(document);
// Ok(())
// }
}
// impl Dumpable for ArtifactsCollection {
// fn dump(&mut self) -> Result<(), DumpError> {
// log::info!("dump artifacts collection...",);
// let error = self.artifacts.par_iter_mut().map(|artifact| {
// log::info!("dumping artifact in {:?}", artifact.output_path());
// artifact.dump()
// })
// .find_any(|result| result.is_err());
// if let Some(error) = error {
// return Err(error.err().unwrap());
// }
// Ok(())
// }
// }