Skip to main content

Module parse

Module parse 

Source
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§

LineError
A ParseError together with the 1-indexed source line on which it occurred.
Records
An iterator yielding one parsed Record per 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 String ready to hand to parse_records.