A high-level parsing crate for IGC flight recorder files.
With most focus on:
- Easy to use
- No run-time asserts meaning that any errors will be through the Result
type
- A panic free crate
You should use this crate if you want to easily, quickly and safely parse igc files.
For additional information on the records use https://xp-soaring.github.io/igcfileformat/igcformat2008.html
Parsing all fixes (B records)
let file = fs::read_to_string("./examples/example.igc").unwrap().parse::<String>().unwrap();
let valid_fixes = file.lines().filter_map(|line| {
match Record::parse(line) {
Ok(Record::B(fix)) => Some(fix),
_ => None,
}
}).collect::<Vec<Fix>>();
println!("{}", valid_fixes.len())
Parsing a single record (L record aka comment)
let comment = match Record::parse("LCOMMENTYCOMMENT").unwrap() {
Record::L(comment) => comment,
_ => panic!("This was not a comment")
};
println!("{}", comment.content);
Parsing entire file and getting all valid fixes
let file = fs::read_to_string("./examples/example.igc").unwrap().parse::<String>().unwrap();
let igc_file = IGCFile::parse(&file).unwrap();
let valid_fixes = igc_file.get_fixes().clone().into_iter()
.filter_map(|fix| match fix {
Ok(fix) => Some(fix),
Err(_) => None,
}).collect::<Vec<Fix>>();
println!("{}", valid_fixes.len())