1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024, 2026 Joe Pearson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! ARINC 424 navigation data parser.
//!
//! This crate provides parser for ARINC 424 [records] with their [fields]. Each
//! record is parsed from 132 bytes and references those. The parser tries to
//! copy as little as possible and the fields provide methods to copy or clone
//! values when needed.
//!
//! # Examples
//!
//! Lets parse John F Kennedy Intl airport and print its coordinates:
//!
//! ```
//! use arinc424::records::Airport;
//!
//! # fn main() -> Result<(), arinc424::Error> {
//! let data = b"SUSAP KJFKK6AJFK 0 145YHN40382374W073464329W013000013 1800018000C MNAR JOHN F KENNEDY INTL 300671912";
//! let airport = Airport::try_from(data.as_slice())?;
//!
//! // now we can print the ICAO code and the position as decimals
//! let icao = airport.icao_code.as_str();
//! let lat = airport.latitude.as_decimal()?;
//! let lon = airport.longitude.as_decimal()?;
//! println!("{icao} at {lat:.4}, {lon:.4}"); // => "KJFK at 40.6399, -73.7786"
//! # Ok(())
//! # }
//! ```
//!
//! You can also read an entire navigation database obtained from your
//! authorities or other data provider. The following uses the [`Records`]
//! iterator to print all airports of the FAA's Coded Instrument Flight
//! Procedures (CIFP):
//!
//! ```
//! # use arinc424::records::{Airport, RecordKind, Records};
//! # use arinc424::Error;
//! # fn main() -> Result<(), Error> {
//! // read the navigation database from file
//! let data = std::fs::read("FAACIFP18").expect("file should be readable");
//!
//! // iterate over all records but print only airports
//! for (kind, bytes) in Records::new(&data) {
//! match kind {
//! RecordKind::Airport => {
//! // Airport only references the bytes and gives us access to the fields
//! let arpt = Airport::try_from(bytes)?;
//! println!("Airport {} ({})", arpt.arpt_ident, arpt.airport_name);
//! }
//! _ => {}
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! [records]: crate::records
//! [fields]: crate::fields
//! [`Records`]: crate::records::Records
pub use *;
// Re-export the derive macro for convenience
pub use Record;
pub use Error;