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 comment;
68mod error;
69mod lonlat;
70mod message;
71mod packet;
72mod position;
73mod position_comment;
74mod server_comment;
75mod server_response;
76mod status;
77mod status_comment;
78mod timestamp;
79mod utils;
80
81use std::str::FromStr;
82
83pub use callsign::Callsign;
84pub use comment::Comment;
85pub use error::{AprsError, EncodeError};
86pub use lonlat::{Latitude, Longitude};
87pub use message::AprsMessage;
88pub use packet::{AprsData, AprsPacket};
89pub use position::AprsPosition;
90pub use position_comment::{AdditionalPrecision, ID, PositionComment};
91pub use server_comment::ServerComment;
92pub use server_response::ServerResponse;
93pub use status::AprsStatus;
94pub use status_comment::StatusComment;
95pub use timestamp::Timestamp;
96
97pub fn parse(s: &str) -> Result<AprsPacket, AprsError> {
98    AprsPacket::from_str(s)
99}