Expand description
Whole-file parsing API.
The low-level Record::parse_line API parses a
single line at a time. This module builds on top of it to parse an entire in-memory IGC
file with a single call, yielding one Record per line.
Because every parsed Record borrows from its source line, the caller must own the
backing buffer (an owned String or a &str that outlives the iterator). Reading a
whole file into memory first is therefore unavoidable — read_to_string is provided
as a small convenience for pulling an impl Read into an owned String.
use igc::records::Record;
let file = "\
ALXVK4AFLIGHT:1
HFDTE230718
B1101355206343N00006198WA0058700558";
for result in igc::parse_records(file) {
match result {
Ok(Record::B(fix)) => assert_eq!(fix.pressure_alt, 587),
Ok(_) => {}
Err(e) => panic!("line {}: {}", e.line_number, e.error),
}
}Structs§
- Line
Error - A
ParseErrortogether with the 1-indexed source line on which it occurred. - Records
- An iterator yielding one parsed
Recordper non-blank line of an IGC file.
Functions§
- parse_
records - Parse every record in an already-in-memory IGC file.
- read_
to_ string - Read an entire reader into an owned
Stringready to hand toparse_records.