ogn_parser/
lib.rs

1//! [APRS] message parser for [Rust]
2//!
3//! [APRS]: http://www.aprs.org/
4//! [Rust]: https://www.rust-lang.org/
5//!
6//! # Usage
7//!
8//! ```rust
9//! extern crate ogn_parser;
10//!
11//! fn main() {
12//!     let result = ogn_parser::parse(
13//!         r"ICA3D17F2>APRS,qAS,dl4mea:/074849h4821.61N\01224.49E^322/103/A=003054"
14//!     );
15//!
16//!     println!("{:#?}", result);
17//!
18//!     // Ok(
19//!     //     AprsPacket {
20//!     //         from: Callsign {
21//!     //             call: "ICA3D17F2",
22//!     //             ssid: None
23//!     //         },
24//!     //         to: Callsign {
25//!     //             call: "APRS",
26//!     //             ssid: None
27//!     //         },
28//!     //         via: [
29//!     //             Callsign {
30//!     //                 call: "qAS",
31//!     //                 ssid: None
32//!     //             },
33//!     //             Callsign {
34//!     //                 call: "dl4mea",
35//!     //                 ssid: None
36//!     //             }
37//!     //         ],
38//!     //         data: Position(
39//!     //             AprsPosition {
40//!     //                 timestamp: Some(
41//!     //                     HHMMSS(
42//!     //                         7,
43//!     //                         48,
44//!     //                         49
45//!     //                     )
46//!     //                 ),
47//!     //                 latitude: 48.360165,
48//!     //                 longitude: 12.408166666666666,
49//!     //                 comment: "322/103/A=003054"
50//!     //             }
51//!     //         )
52//!     //     }
53//!     // )
54//! }
55//! ```
56
57// `!(-90. ..=90.).contains(&value)` seems worse than `value > 90. || value < -90.`
58#![allow(clippy::manual_range_contains)]
59
60extern crate thiserror;
61
62#[cfg(test)]
63#[macro_use]
64extern crate approx;
65
66mod callsign;
67mod error;
68mod lonlat;
69mod message;
70mod packet;
71mod position;
72mod position_comment;
73mod server_comment;
74mod server_response;
75mod status;
76mod status_comment;
77mod timestamp;
78mod utils;
79
80use std::str::FromStr;
81
82pub use callsign::Callsign;
83pub use error::{AprsError, EncodeError};
84pub use lonlat::{Latitude, Longitude};
85pub use message::AprsMessage;
86pub use packet::{AprsData, AprsPacket};
87pub use position::AprsPosition;
88pub use position_comment::{AdditionalPrecision, ID, PositionComment};
89pub use server_comment::ServerComment;
90pub use server_response::ServerResponse;
91pub use status::AprsStatus;
92pub use status_comment::StatusComment;
93pub use timestamp::Timestamp;
94
95pub fn parse(s: &str) -> Result<AprsPacket, AprsError> {
96    AprsPacket::from_str(s)
97}