refactor: variable names

This commit is contained in:
selene 2025-12-07 22:09:21 +01:00
parent 9e78920497
commit 3342ef5332
Signed by: sel
SSH key fingerprint: SHA256:33R/4Rx5Lu4o81LyJyXdMrmP5CJ6j7j1Soo0Dn7mKc0

View file

@ -78,22 +78,28 @@ impl ObjectInstance {
// destination_parts[1] is the property under `input` (value)
let destination_parts: Vec<&str> = destination.splitn(2, ":").collect();
// first item of tuple is for the source object template, second is for the source object instance
let source_category = match source_parts[0] {
"input" => (template.input, &obj.input),
"local" => (template.local, &obj.local),
"remote" => (template.remote, &obj.remote),
let source_instance_category = match source_parts[0] {
"input" => &obj.input,
"local" => &obj.local,
"remote" => &obj.remote,
_ => return Err(format!("the category specified in the transformation source ({}) is invalid (must be input OR local OR remote)", source_parts[0]))
};
let template_property = match source_category.0.get(source_parts[1]) {
let source_template_category = match source_parts[0] {
"input" => template.input,
"local" => template.local,
"remote" => template.remote,
_ => unreachable!()
};
let template_property = match source_template_category.get(source_parts[1]) {
Some(template_property) => template_property,
None => return Err(format!("the property specified as the transformation source ({}) doesn't exist in the template", source))
};
if template_property.transforms.contains(&destination.to_string()) {
let result = ObjectInstance::from_template(destination_parts[0], json!({
destination_parts[1]: source_category.1.get(source_parts[1])
destination_parts[1]: source_instance_category.get(source_parts[1])
}))?;
Ok(result)