#![doc = document_features::document_features!()]
#![warn(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]
#![doc(
html_logo_url = "https://gitlab.com/mavka/spec/protocols/mavlink/mavspec-definitions/-/raw/main/avatar.png?ref_type=heads",
html_favicon_url = "https://gitlab.com/mavka/spec/protocols/mavlink/mavspec-definitions/-/raw/main/avatar.png?ref_type=heads"
)]
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "std")]
mod std_utils {
use lazy_static::lazy_static;
use mavinspect::protocol::Protocol;
use std::ops::Deref;
lazy_static! {
static ref PROTOCOL: Protocol = {
#[cfg(not(feature = "compress"))]
return postcard::from_bytes(get_metadata_binary()).unwrap_or_default();
#[cfg(feature = "compress")]
{
let bytes_compressed = get_metadata_binary();
if let Ok(data) = miniz_oxide::inflate::decompress_to_vec(&bytes_compressed) {
postcard::from_bytes(data.as_slice()).unwrap_or_default()
} else {
Protocol::default()
}
}
};
}
const fn get_metadata_binary() -> &'static [u8] {
#[cfg(not(target_os = "windows"))]
return include_bytes!(concat!(env!("OUT_DIR"), "/", "mavlink-protocol.postcard")).as_slice();
#[cfg(target_os = "windows")]
return include_bytes!(concat!(env!("OUT_DIR"), "\\", "mavlink-protocol.postcard")).as_slice();
}
pub fn protocol() -> &'static Protocol {
PROTOCOL.deref()
}
pub const DEFAULT_DIALECT_SEQUENCE: [&str; 5] =
["all", "ardupilotmega", "common", "standard", "minimal"];
}
#[cfg(feature = "std")]
pub use std_utils::{protocol, DEFAULT_DIALECT_SEQUENCE};