Checking table integrity
The data model involves lazy checking of inputs. In other words, we can add invalid row data that is not caught by the "add row" functions. We inherit this behavior from the C API.
We can check that the tables contain valid data by:
let mut tables = tskit::TableCollection::new(100.0).unwrap();
// Everything about this edge is wrong...
tables.add_edge(-1.0, 110.0, 0, 1).unwrap();
// ...and we can catch that here
match tables.check_integrity(tskit::TableIntegrityCheckFlags::default()) {
Ok(code) => panic!("expected Err(e) but got code: {}", code),
// tskit::TskitError can be formatted into the same
// error messages that tskit-c/tskit-python give.
Err(e) => println!("{}", e),
}