#[must_use]
#[allow(clippy::too_many_lines)]
pub fn lookup(code: [u8; 2]) -> Option<&'static str> {
Some(match &code {
b"10" | b"17" => "Arrival info",
b"11" | b"QA" => "Out (gate)",
b"12" | b"QB" => "Off (wheels)",
b"13" | b"QC" => "On (wheels)",
b"14" | b"QD" => "In (gate)",
b"15" | b"80" => "Departure",
b"16" | b"25" | b"32" | b"35" | b"40" | b"44" | b"45" | b"4M" | b"4N" | b"5U" | b"81"
| b"A6" | b"A8" | b"QH" | b"QM" | b"QP" | b"QQ" | b"QR" => "Position",
b"1F" | b"82" => "Free text",
b"1G" => "Gate request",
b"1H" => "Gate assignment",
b"1L" | b"2C" | b"30" | b"57" | b"M1" | b"QG" => "Position report",
b"1S" | b"26" | b"5Z" | b"8S" => "Schedule",
b"20" => "Departure clearance",
b"21" => "Departure clearance reply",
b"22" | b"83" => "Pre-departure clearance",
b"23" => "Datalink expedite",
b"27" => "Schedule (revision)",
b"2N" => "Takeoff time",
b"2Z" => "Destination update",
b"33" => "Fuel report",
b"39" => "Maintenance ground report",
b"51" => "Ground service request",
b"52" | b"8A" => "Engine maintenance",
b"5Y" => "OOOI report",
b"70" => "Voice contact request",
b"7A" | b"7B" | b"7C" => "Test message",
b"8D" => "Dispatch reply",
b"8E" => "ETA report",
b"A0" => "Test",
b"A7" => "Pre-departure clearance request",
b"A9" => "Pre-departure clearance reply",
b"AA" | b"Q5" => "Engine data",
b"B1" | b"BA" => "Weather request",
b"B2" => "Weather information",
b"B3" => "Weather (text)",
b"B4" => "Weather (route)",
b"B5" => "Weather (terminal)",
b"B6" => "Weather (en-route)",
b"B7" => "Weather (clearance)",
b"B8" => "Weather (SIGMET)",
b"B9" => "Weather (other)",
b"C0" => "Uplink command",
b"C1" => "ATC",
b"C2" => "ATC clearance request",
b"C3" => "ATC reply",
b"H1" => "Crew message",
b"H2" => "Free text uplink",
b"H3" => "Free text downlink",
b"Q0" => "Link test",
b"Q1" => "ATIS",
b"Q2" => "ACARS network test",
b"Q3" => "Voice circuit test",
b"Q4" => "Navaids",
b"Q6" => "Engine display data",
b"Q7" => "Component maintenance",
b"QE" => "OOOI summary",
b"QF" => "OOOI (extended)",
b"QK" => "Voice request",
b"QL" => "ATIS (alt)",
b"QN" | b"QS" => "Diversion",
b"QT" => "ACARS request",
b"RB" => "Schedule (alias for 26)",
b"_d" => "General downlink",
b"_e" => "General uplink",
_ => return None,
})
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
#[test]
fn lookup_known_labels() {
assert_eq!(lookup(*b"H1"), Some("Crew message"));
assert_eq!(lookup(*b"Q0"), Some("Link test"));
assert_eq!(lookup(*b"M1"), Some("Position report"));
assert_eq!(lookup(*b"_d"), Some("General downlink"));
assert_eq!(lookup(*b"RB"), Some("Schedule (alias for 26)"));
}
#[test]
fn lookup_numeric_labels() {
assert_eq!(lookup(*b"10"), Some("Arrival info"));
assert_eq!(lookup(*b"11"), Some("Out (gate)"));
assert_eq!(lookup(*b"12"), Some("Off (wheels)"));
assert_eq!(lookup(*b"13"), Some("On (wheels)"));
assert_eq!(lookup(*b"14"), Some("In (gate)"));
}
#[test]
fn lookup_unknown_returns_none() {
assert_eq!(lookup([0xFF, 0xFF]), None);
assert_eq!(lookup(*b"ZZ"), None);
}
}