Skip to main content

mavlink/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4//! Rust implementation of the MAVLink UAV messaging protocol, with bindings for all dialects.
5//! This crate provides message set code generation, packet building, parsing and connection handling for blocking and asynchronous I/O.
6//!
7//! # Feature flags
8//! The `mavlink` crate uses a number of [feature flags] to reduce the amount of compiled code by making certain functions and MAVLink message sets (dialects) optional.
9//! These feature flags are available to control the provided functionalities:
10//!
11//! - `std`: Enables the usage of `std` in `mavlink`, enabled by default, this can be disabled for embedded applications.
12//! - `transport-direct-serial`: Enable serial MAVLink connections, enabled by default.
13//! - `transport-udp`: Enables UDP based MAVLink connections, enabled by default.
14//! - `transport-tcp`: Enables TCP based MAVLink connections, enabled by default.
15//! - `mav2-message-signing`: Enable support for [MAVLink 2 message signing]
16//! - `embedded`: Enables embedded support using the [embedded-io] crate, incompatible with `tokio`.
17//! - `tokio`: Enable support for asynchronous I/O using [tokio], incompatible with `embedded`.
18//! - `serde`: Enables [serde] support in generated message sets, enabled by default.
19//! - `format-generated-code`: Generated MAVLink message set code will be formatted, requires `rustfmt` to be installed, enabled by default.
20//! - `mav2-message-extensions`: Generated MAVLink message set code will include [MAVLink 2 message extensions].
21//! - `arbitrary`: Enable support for the [arbitrary] crate.
22//! - `ts-rs`: Enable TypeScript code generation via [ts-rs].
23//!
24//! Either `std` or `embedded` must be enabled.
25//!
26//! Each MAVlink message set (dialect) can be enabled using its feature flag. The following message set feature flags are available:
27//! - `dialect-all`
28//! - `dialect-ardupilotmega`, enabled by default
29//! - `dialect-common`, enabled by default
30//! - `dialect-asluav`
31//! - `dialect-avssuas`
32//! - `dialect-cubepilot`
33//! - `dialect-csairlink`
34//! - `dialect-development`
35//! - `dialect-icarous`
36//! - `dialect-loweheiser`
37//! - `dialect-marsh`
38//! - `dialect-minimal`
39//! - `dialect-paparazzi`
40//! - `dialect-python_array_test`
41//! - `dialect-standard`
42//! - `dialect-stemstudios`
43//! - `dialect-storm32`
44//! - `dialect-test`
45//! - `dialect-ualberta`
46//! - `dialect-uavionix`
47//!
48//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
49//! [MAVLink 2 message signing]: https://mavlink.io/en/guide/message_signing.html
50//! [MAVLink 2 message extensions]: https://mavlink.io/en/guide/define_xml_element.html#message_extensions
51//! [embedded-io]: https://crates.io/crates/embedded-io
52//! [embedded-hal]: https://crates.io/crates/embedded-hal
53//! [tokio]: https://crates.io/crates/tokio
54//! [serde]: https://crates.io/crates/serde
55//! [arbitrary]: https://crates.io/crates/arbitrary
56//! [ts-rs]: https://crates.io/crates/ts-rs
57
58#[cfg(all(feature = "std", feature = "embedded", not(any(clippy, doc))))]
59compile_error!("`std` and `embedded` features cannot be enabled together");
60
61pub mod dialects {
62    //! MAVLink dialect Rust bindings generated by mavlink-bindgen.
63    //!
64    //! Enable a dialect by enabling its Cargo feature:
65    //! - dialect-ardupilotmega
66    //! - dialect-asluav
67    //! - dialect-avssuas
68    //! - dialect-common
69    //! - dialect-csairlink
70    //! - dialect-cubepilot
71    //! - dialect-development
72    //! - dialect-icarous
73    //! - dialect-loweheiser
74    //! - dialect-marsh
75    //! - dialect-minimal
76    //! - dialect-paparazzi
77    //! - dialect-python_array_test
78    //! - dialect-standard
79    //! - dialect-stemstudios
80    //! - dialect-storm32
81    //! - dialect-test
82    //! - dialect-ualberta
83    //! - dialect-uavionix
84
85    /// Git SHA of the MAVLink definitions used to generate the bindings, when available.
86    ///
87    /// This is [`None`] when `git` fails to resolve the commit SHA.
88    pub const MAVLINK_DEFINITIONS_SHA: Option<&str> = option_env!("MAVLINK_SHA");
89
90    include!(concat!(env!("OUT_DIR"), "/mod.rs"));
91}
92
93pub use mavlink_core::*;