use crate::error::{Result, ThundError};
use crate::ir::Pipeline;
pub fn from_ron(text: &str) -> Result<Pipeline> {
let result: Result<Pipeline> = (|| {
let p: Pipeline = ron::from_str(text).map_err(|e| ThundError::Dsl(e.to_string()))?;
p.validate()?;
Ok(p)
})();
crate::functional_status(
"knut-thund/dsl",
"from_ron",
result.is_ok(),
&match &result {
Ok(p) => p.name.clone(),
Err(e) => e.to_string(),
},
);
result
}
pub fn to_ron(pipeline: &Pipeline) -> Result<String> {
let result = ron::ser::to_string_pretty(pipeline, ron::ser::PrettyConfig::default())
.map_err(|e| ThundError::Dsl(e.to_string()));
crate::functional_status("knut-thund/dsl", "to_ron", result.is_ok(), &pipeline.name);
result
}