U66KCVZMSQF6B4S3V3TBN4P4KKP4CWCEX7XB63QCMLPLN7V5NSWQC
}
pub fn render(&mut self) {
let mut files = self.branch.clone();
if let Some(File { document: Document::Other(mut doc), ..}) = files.pop() {
files
.iter()
.filter_map(
|f| {
match f {
File { document: Document::Karbonfile { transformations: ts, .. }, .. } => {
return Some(ts);
},
_ => {
return None;
},
}
}
)
.flatten()
.for_each(|t| t.apply(&mut doc));
self.result = doc;
}
}
}
impl Transformation {
pub fn apply(&self, doc: &mut Value) {
match self {
Transformation::PatchSet {
filters: fs,
patches: ps,
} => {
if fs.iter().any(|f| f.matches(doc)) {
for (ptr, patch) in ps.into_iter() {
match patch {
JsonPatch::Add(_) => {
},
JsonPatch::Replace(v) => {
*ptr.get_mut(doc) = v.clone();
},
JsonPatch::Remove => {
},
}
}
}
},
}
for (ptr, val) in map.into_iter() {
if *ptr.get_mut(doc) != val.clone() {
return false;
}
}
return true;
return map
.into_iter()
.all(|(ptr, val)| {
*ptr.get_mut(doc) == val.clone()
});
let mut branch = variant.branch;
branch.push(file);
let mut new_variant = Variant {
branch: branch,
..variant
};
// ToDo: Handle karbonfiles without resources (only generators)