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
//! **MAVInspect** is a library for parsing MAVLink
//! [message definitions](https://github.com/mavlink/mavlink/tree/master/message_definitions/v1.0).
//!
//! [`repository`](https://gitlab.com/mavka/libs/mavinspect) |
//! [`crate`](https://crates.io/crates/mavinspect) |
//! [`API docs`](https://docs.rs/mavinspect/latest/mavinspect/) |
//! [`issues`](https://gitlab.com/mavka/libs/mavinspect/-/issues)
//!
//! # Usage
//!
//! Discover and parse MAVLink XML using [`Inspector`]:
//!
//! ```rust
//! use std::env;
//! use mavinspect::parser::Inspector;
//!
//! // Instantiate inspector and load XML definitions from several locations
//! let inspector = Inspector::builder()
//! .set_sources(&[
//! "./message_definitions/standard",
//! "./message_definitions/extra",
//! ])
//! .build()
//! .unwrap();
//!
//! // Parse all XML definitions
//! let protocol = inspector.parse().unwrap();
//!
//! // Get `crazyflight` custom dialect
//! let crazyflight = protocol.dialects().get("crazy_flight").unwrap();
//!
//! // Get `DUMMYFLIGHT_OUTCRY` message
//! let outcry_message = crazyflight.messages().get(&54000u32).unwrap();
//! assert_eq!(outcry_message.name(), "CRAZYFLIGHT_OUTCRY");
//! println!("\n`CRAZYFLIGHT_OUTCRY` message: {:#?}", outcry_message);
//! ```
//!
//! Here we obtain an instance of [`Protocol`](protocol::Protocol) that contains a collection of
//! dialects. Each [`Dialect`](protocol::Dialect) contains MAVLink [`enums`](protocol::Dialect::enums) and
//! [`messages`](protocol::Dialect::messages) as well as additional information (like version or dialect dependencies).
//!
//! # Cargo Features
//!
//! * `serde` — add [Serde](https://serde.rs) support.
//!
//! # Specification API
//!
//! MAVLink entities are defined in the [`protocol`] module. The root of the specification is
//! [`Protocol`](protocol::Protocol) struct that contains [`Dialects`](protocol::Dialect). The latter contains dialect
//! metadata, [`messages`](protocol::Dialect::messages) and [`enums`](protocol::Dialect::enums).
//!
//! Most of the entities with complex validation rules and lots of parameters are using
//! [builder](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html) instead of direct
//! instantiation (no constructors). We assume that library clients prefer to use XML definitions as a ground truth for
//! their dialects and are not very interested in manual creation of Rust entities. However, this possibility remains
//! open yet not encouraged.
//!
//! All entities optionally support [Serde](https://serde.rs) and are thread-safe.
//!
//! # Errors
//!
//! All errors are variants (or sub-variants) of [`Error`](errors::Error). Fallible functions and methods return
//! [`Result`] type.
#![warn(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]
#![doc(
html_logo_url = "https://gitlab.com/mavka/libs/mavinspect/-/raw/main/avatar.png?ref_type=heads",
html_favicon_url = "https://gitlab.com/mavka/libs/mavinspect/-/raw/main/avatar.png?ref_type=heads"
)]
pub mod parser;
#[doc(inline)]
pub use parser::Inspector;
pub mod errors;
pub mod protocol;
pub mod utils;