sanitise!() { /* proc-macro */ }
Expand description
Cleans up and validates data.
The first argument must be either a string literal or a macro call that expands to a string literal. The second argument must be an expression that resolves to a tuple of borrowed slices of options containing the values of the input file. The slices must all be the same length. This is more clearly explained by the examples.
Examples
let time = vec![Some(0), Some(15), Some(127)];
let pulse = vec![Some(67), Some(45), Some(132)];
let movement = vec![Some(0), Some(1), Some(1)];
let ((time_millis, pulse, movement),) = sanitise!(
r#"
processes:
- name: validate
columns:
- title: time
column-type: integer
- title: pulse
column-type: integer
max: 100
min: 40
on-invalid: average
valid-streak: 3
- title: movement
column-type: integer
valid-values: [0, 1]
output-type: boolean
output: "value == 1"
"#,
(&time, &pulse, &movement),
).unwrap();
println!("time_millis,pulse,movement");
for ((time_millis, pulse), movement) in zip(zip(time_millis, pulse), movement) {
println!("{time_millis},{pulse},{movement}")
}