pub fn parse(input: &str) -> Result<ParsedReport, ParseError>Expand description
Parses a METAR, SPECI, or TAF string, automatically selecting the correct decoder based on the leading token.
| Leading token | Parser used |
|---|---|
TAF | parse_taf |
METAR, SPECI, none | parse_metar |
This function is tolerant: unrecognised groups are collected in
unparsed_groups rather than causing an error. Use parse_strict for
strict validation.
§Arguments
input- Raw METAR or TAF string.
§Errors
Returns ParseError::Metar or ParseError::Taf if the selected
parser rejects the input (e.g. empty string or missing mandatory fields).
§Example
use metar_taf_parser::{parse, ParsedReport};
let metar = parse("METAR LIRF 121250Z 18010KT 9999 FEW030 18/12 Q1015").unwrap();
assert!(matches!(metar, ParsedReport::Metar(_)));
let taf = parse("TAF LIRF 121100Z 1212/1318 18010KT 9999 SCT020").unwrap();
assert!(matches!(taf, ParsedReport::Taf(_)));