|
| 1 | +--- |
| 2 | +source: mavlink-bindgen/tests/e2e_snapshots.rs |
| 3 | +assertion_line: 26 |
| 4 | +expression: contents |
| 5 | +--- |
| 6 | +#![doc = "MAVLink deprecated dialect."] |
| 7 | +#![doc = ""] |
| 8 | +#![doc = "This file was automatically generated, do not edit."] |
| 9 | +#![allow(deprecated)] |
| 10 | +#[cfg(feature = "arbitrary")] |
| 11 | +use arbitrary::Arbitrary; |
| 12 | +#[allow(unused_imports)] |
| 13 | +use bitflags::bitflags; |
| 14 | +use mavlink_core::{bytes::Bytes, bytes_mut::BytesMut, MavlinkVersion, Message, MessageData}; |
| 15 | +#[allow(unused_imports)] |
| 16 | +use num_derive::FromPrimitive; |
| 17 | +#[allow(unused_imports)] |
| 18 | +use num_derive::ToPrimitive; |
| 19 | +#[allow(unused_imports)] |
| 20 | +use num_traits::FromPrimitive; |
| 21 | +#[allow(unused_imports)] |
| 22 | +use num_traits::ToPrimitive; |
| 23 | +#[cfg(feature = "serde")] |
| 24 | +use serde::{Deserialize, Serialize}; |
| 25 | +#[derive(Debug, Copy, Clone, PartialEq, FromPrimitive, ToPrimitive)] |
| 26 | +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 27 | +#[cfg_attr(feature = "serde", serde(tag = "type"))] |
| 28 | +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] |
| 29 | +#[repr(u32)] |
| 30 | +pub enum MavFrame { |
| 31 | + #[deprecated = "Use MAV_FRAME_GLOBAL in COMMAND_INT (and elsewhere) as a synonymous replacement. See `MAV_FRAME_GLOBAL` (Deprecated since 2024-03)"] |
| 32 | + MAV_FRAME_GLOBAL_INT = 5, |
| 33 | +} |
| 34 | +impl MavFrame { |
| 35 | + pub const DEFAULT: Self = Self::MAV_FRAME_GLOBAL_INT; |
| 36 | +} |
| 37 | +impl Default for MavFrame { |
| 38 | + fn default() -> Self { |
| 39 | + Self::DEFAULT |
| 40 | + } |
| 41 | +} |
| 42 | +#[derive(Debug, Copy, Clone, PartialEq, FromPrimitive, ToPrimitive)] |
| 43 | +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 44 | +#[cfg_attr(feature = "serde", serde(tag = "type"))] |
| 45 | +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] |
| 46 | +#[repr(u32)] |
| 47 | +#[deprecated = " See `GIMBAL_MANAGER_FLAGS` (Deprecated since 2020-01)"] |
| 48 | +pub enum MavMountMode { |
| 49 | + MAV_MOUNT_MODE_RETRACT = 0, |
| 50 | +} |
| 51 | +impl MavMountMode { |
| 52 | + pub const DEFAULT: Self = Self::MAV_MOUNT_MODE_RETRACT; |
| 53 | +} |
| 54 | +impl Default for MavMountMode { |
| 55 | + fn default() -> Self { |
| 56 | + Self::DEFAULT |
| 57 | + } |
| 58 | +} |
| 59 | +#[deprecated = "To be removed / merged with TIMESYNC. See `TIMESYNC` (Deprecated since 2011-08)"] |
| 60 | +#[derive(Debug, Clone, PartialEq)] |
| 61 | +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 62 | +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] |
| 63 | +pub struct PING_DATA { |
| 64 | + pub time_usec: u64, |
| 65 | + pub seq: u32, |
| 66 | + pub target_system: u8, |
| 67 | + pub target_component: u8, |
| 68 | +} |
| 69 | +impl PING_DATA { |
| 70 | + pub const ENCODED_LEN: usize = 14usize; |
| 71 | + pub const DEFAULT: Self = Self { |
| 72 | + time_usec: 0_u64, |
| 73 | + seq: 0_u32, |
| 74 | + target_system: 0_u8, |
| 75 | + target_component: 0_u8, |
| 76 | + }; |
| 77 | + #[cfg(feature = "arbitrary")] |
| 78 | + pub fn random<R: rand::RngCore>(rng: &mut R) -> Self { |
| 79 | + use arbitrary::{Arbitrary, Unstructured}; |
| 80 | + let mut buf = [0u8; 1024]; |
| 81 | + rng.fill_bytes(&mut buf); |
| 82 | + let mut unstructured = Unstructured::new(&buf); |
| 83 | + Self::arbitrary(&mut unstructured).unwrap_or_default() |
| 84 | + } |
| 85 | +} |
| 86 | +impl Default for PING_DATA { |
| 87 | + fn default() -> Self { |
| 88 | + Self::DEFAULT.clone() |
| 89 | + } |
| 90 | +} |
| 91 | +impl MessageData for PING_DATA { |
| 92 | + type Message = MavMessage; |
| 93 | + const ID: u32 = 4u32; |
| 94 | + const NAME: &'static str = "PING"; |
| 95 | + const EXTRA_CRC: u8 = 237u8; |
| 96 | + const ENCODED_LEN: usize = 14usize; |
| 97 | + fn deser( |
| 98 | + _version: MavlinkVersion, |
| 99 | + __input: &[u8], |
| 100 | + ) -> Result<Self, ::mavlink_core::error::ParserError> { |
| 101 | + let avail_len = __input.len(); |
| 102 | + let mut payload_buf = [0; Self::ENCODED_LEN]; |
| 103 | + let mut buf = if avail_len < Self::ENCODED_LEN { |
| 104 | + payload_buf[0..avail_len].copy_from_slice(__input); |
| 105 | + Bytes::new(&payload_buf) |
| 106 | + } else { |
| 107 | + Bytes::new(__input) |
| 108 | + }; |
| 109 | + let mut __struct = Self::default(); |
| 110 | + __struct.time_usec = buf.get_u64_le(); |
| 111 | + __struct.seq = buf.get_u32_le(); |
| 112 | + __struct.target_system = buf.get_u8(); |
| 113 | + __struct.target_component = buf.get_u8(); |
| 114 | + Ok(__struct) |
| 115 | + } |
| 116 | + fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize { |
| 117 | + let mut __tmp = BytesMut::new(bytes); |
| 118 | + #[allow(clippy::absurd_extreme_comparisons)] |
| 119 | + #[allow(unused_comparisons)] |
| 120 | + if __tmp.remaining() < Self::ENCODED_LEN { |
| 121 | + panic!( |
| 122 | + "buffer is too small (need {} bytes, but got {})", |
| 123 | + Self::ENCODED_LEN, |
| 124 | + __tmp.remaining(), |
| 125 | + ) |
| 126 | + } |
| 127 | + __tmp.put_u64_le(self.time_usec); |
| 128 | + __tmp.put_u32_le(self.seq); |
| 129 | + __tmp.put_u8(self.target_system); |
| 130 | + __tmp.put_u8(self.target_component); |
| 131 | + if matches!(version, MavlinkVersion::V2) { |
| 132 | + let len = __tmp.len(); |
| 133 | + ::mavlink_core::utils::remove_trailing_zeroes(&bytes[..len]) |
| 134 | + } else { |
| 135 | + __tmp.len() |
| 136 | + } |
| 137 | + } |
| 138 | +} |
| 139 | +#[derive(Clone, PartialEq, Debug)] |
| 140 | +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
| 141 | +#[cfg_attr(feature = "serde", serde(tag = "type"))] |
| 142 | +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] |
| 143 | +#[repr(u32)] |
| 144 | +pub enum MavMessage { |
| 145 | + #[deprecated = "To be removed / merged with TIMESYNC. See `TIMESYNC` (Deprecated since 2011-08)"] |
| 146 | + PING(PING_DATA), |
| 147 | +} |
| 148 | +impl MavMessage { |
| 149 | + pub const fn all_ids() -> &'static [u32] { |
| 150 | + &[4u32] |
| 151 | + } |
| 152 | +} |
| 153 | +impl Message for MavMessage { |
| 154 | + fn parse( |
| 155 | + version: MavlinkVersion, |
| 156 | + id: u32, |
| 157 | + payload: &[u8], |
| 158 | + ) -> Result<Self, ::mavlink_core::error::ParserError> { |
| 159 | + match id { |
| 160 | + PING_DATA::ID => PING_DATA::deser(version, payload).map(Self::PING), |
| 161 | + _ => Err(::mavlink_core::error::ParserError::UnknownMessage { id }), |
| 162 | + } |
| 163 | + } |
| 164 | + fn message_name(&self) -> &'static str { |
| 165 | + match self { |
| 166 | + Self::PING(..) => PING_DATA::NAME, |
| 167 | + } |
| 168 | + } |
| 169 | + fn message_id(&self) -> u32 { |
| 170 | + match self { |
| 171 | + Self::PING(..) => PING_DATA::ID, |
| 172 | + } |
| 173 | + } |
| 174 | + fn message_id_from_name(name: &str) -> Option<u32> { |
| 175 | + match name { |
| 176 | + PING_DATA::NAME => Some(PING_DATA::ID), |
| 177 | + _ => None, |
| 178 | + } |
| 179 | + } |
| 180 | + fn default_message_from_id(id: u32) -> Option<Self> { |
| 181 | + match id { |
| 182 | + PING_DATA::ID => Some(Self::PING(PING_DATA::default())), |
| 183 | + _ => None, |
| 184 | + } |
| 185 | + } |
| 186 | + #[cfg(feature = "arbitrary")] |
| 187 | + fn random_message_from_id<R: rand::RngCore>(id: u32, rng: &mut R) -> Option<Self> { |
| 188 | + match id { |
| 189 | + PING_DATA::ID => Some(Self::PING(PING_DATA::random(rng))), |
| 190 | + _ => None, |
| 191 | + } |
| 192 | + } |
| 193 | + fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize { |
| 194 | + match self { |
| 195 | + Self::PING(body) => body.ser(version, bytes), |
| 196 | + } |
| 197 | + } |
| 198 | + fn extra_crc(id: u32) -> u8 { |
| 199 | + match id { |
| 200 | + PING_DATA::ID => PING_DATA::EXTRA_CRC, |
| 201 | + _ => 0, |
| 202 | + } |
| 203 | + } |
| 204 | + fn target_system_id(&self) -> Option<u8> { |
| 205 | + match self { |
| 206 | + Self::PING(inner) => Some(inner.target_system), |
| 207 | + _ => None, |
| 208 | + } |
| 209 | + } |
| 210 | + fn target_component_id(&self) -> Option<u8> { |
| 211 | + match self { |
| 212 | + Self::PING(inner) => Some(inner.target_component), |
| 213 | + _ => None, |
| 214 | + } |
| 215 | + } |
| 216 | +} |
0 commit comments