-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Milestone
Description
connector.rs
// What type of array serialization / deserialization will we need between these two data types
// at runtime TODO - take into account the subroute on the output
// calculate how many levels of array nesting it removes via number of '/' / levels?
// let array_level_serde = connection.from_io.datatype().array_order()? - connection.to_io.datatype().array_order()?;
let array_level_serde = connection.to_io.datatype().array_order()?;
Turns out this is done at runtime:
fn type_convert_and_send(function: &mut Function, destination: &OutputConnection, value: &Value) {
if destination.is_generic() {
function.send(destination.io_number, value);
} else {
match Self::array_order(value) - destination.array_level_serde {
0 => function.send(destination.io_number, value),
1 => function.send_iter(destination.io_number, value),
2 => for array in value.as_array().unwrap().iter() {
function.send_iter(destination.io_number, array)
},
-1 => function.send(destination.io_number, &json!([value])),
-2 => function.send(destination.io_number, &json!([[value]])),
_ => error!("Unable to handle difference in array order")
}
}
}
this could all be pre-calculated at compile time and avoid the need for
Self::array_order(value)
in run_state.rs - UNLESS it depends on what is output (i..e can vary at runtime?)