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-matrixpilot`
39//! - `dialect-minimal`
40//! - `dialect-paparazzi`
41//! - `dialect-python_array_test`
42//! - `dialect-standard`
43//! - `dialect-stemstudios`
44//! - `dialect-storm32`
45//! - `dialect-test`
46//! - `dialect-ualberta`
47//! - `dialect-uavionix`
48//!
49//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
50//! [MAVLink 2 message signing]: https://mavlink.io/en/guide/message_signing.html
51//! [MAVLink 2 message extensions]: https://mavlink.io/en/guide/define_xml_element.html#message_extensions
52//! [embedded-io]: https://crates.io/crates/embedded-io
53//! [embedded-hal]: https://crates.io/crates/embedded-hal
54//! [tokio]: https://crates.io/crates/tokio
55//! [serde]: https://crates.io/crates/serde
56//! [arbitrary]: https://crates.io/crates/arbitrary
57//! [ts-rs]: https://crates.io/crates/ts-rs
58
59#[cfg(all(feature = "std", feature = "embedded", not(any(clippy, doc))))]
60compile_error!("`std` and `embedded` features cannot be enabled together");
61
62pub mod dialects {
63    //! MAVLink dialect Rust bindings generated by mavlink-bindgen.
64    //!
65    //! Enable a dialect by enabling its Cargo feature:
66    //! - dialect-ardupilotmega
67    //! - dialect-asluav
68    //! - dialect-avssuas
69    //! - dialect-common
70    //! - dialect-csairlink
71    //! - dialect-cubepilot
72    //! - dialect-development
73    //! - dialect-icarous
74    //! - dialect-loweheiser
75    //! - dialect-marsh
76    //! - dialect-matrixpilot
77    //! - dialect-minimal
78    //! - dialect-paparazzi
79    //! - dialect-python_array_test
80    //! - dialect-standard
81    //! - dialect-stemstudios
82    //! - dialect-storm32
83    //! - dialect-test
84    //! - dialect-ualberta
85    //! - dialect-uavionix
86    include!(concat!(env!("OUT_DIR"), "/mod.rs"));
87}
88
89pub use mavlink_core::*;