|
| 1 | +pub mod rmw { |
| 2 | + #[cfg(feature = "serde")] |
| 3 | + use serde::{Deserialize, Serialize}; |
| 4 | + |
| 5 | + #[link(name = "builtin_interfaces__rosidl_typesupport_c")] |
| 6 | + extern "C" { |
| 7 | + fn rosidl_typesupport_c__get_message_type_support_handle__builtin_interfaces__msg__Duration( |
| 8 | + ) -> *const std::os::raw::c_void; |
| 9 | + } |
| 10 | + |
| 11 | + #[link(name = "builtin_interfaces__rosidl_generator_c")] |
| 12 | + extern "C" { |
| 13 | + fn builtin_interfaces__msg__Duration__init(msg: *mut Duration) -> bool; |
| 14 | + fn builtin_interfaces__msg__Duration__Sequence__init( |
| 15 | + seq: *mut rosidl_runtime_rs::Sequence<Duration>, |
| 16 | + size: usize, |
| 17 | + ) -> bool; |
| 18 | + fn builtin_interfaces__msg__Duration__Sequence__fini( |
| 19 | + seq: *mut rosidl_runtime_rs::Sequence<Duration>, |
| 20 | + ); |
| 21 | + fn builtin_interfaces__msg__Duration__Sequence__copy( |
| 22 | + in_seq: &rosidl_runtime_rs::Sequence<Duration>, |
| 23 | + out_seq: *mut rosidl_runtime_rs::Sequence<Duration>, |
| 24 | + ) -> bool; |
| 25 | + } |
| 26 | + |
| 27 | + // Corresponds to builtin_interfaces__msg__Duration |
| 28 | + #[repr(C)] |
| 29 | + #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
| 30 | + #[derive(Clone, Debug, PartialEq, PartialOrd)] |
| 31 | + pub struct Duration { |
| 32 | + pub sec: i32, |
| 33 | + pub nanosec: u32, |
| 34 | + } |
| 35 | + |
| 36 | + impl Default for Duration { |
| 37 | + fn default() -> Self { |
| 38 | + unsafe { |
| 39 | + let mut msg = std::mem::zeroed(); |
| 40 | + if !builtin_interfaces__msg__Duration__init(&mut msg as *mut _) { |
| 41 | + panic!("Call to builtin_interfaces__msg__Duration__init() failed"); |
| 42 | + } |
| 43 | + msg |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + impl rosidl_runtime_rs::SequenceAlloc for Duration { |
| 49 | + fn sequence_init(seq: &mut rosidl_runtime_rs::Sequence<Self>, size: usize) -> bool { |
| 50 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 51 | + unsafe { builtin_interfaces__msg__Duration__Sequence__init(seq as *mut _, size) } |
| 52 | + } |
| 53 | + fn sequence_fini(seq: &mut rosidl_runtime_rs::Sequence<Self>) { |
| 54 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 55 | + unsafe { builtin_interfaces__msg__Duration__Sequence__fini(seq as *mut _) } |
| 56 | + } |
| 57 | + fn sequence_copy( |
| 58 | + in_seq: &rosidl_runtime_rs::Sequence<Self>, |
| 59 | + out_seq: &mut rosidl_runtime_rs::Sequence<Self>, |
| 60 | + ) -> bool { |
| 61 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 62 | + unsafe { builtin_interfaces__msg__Duration__Sequence__copy(in_seq, out_seq as *mut _) } |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + impl rosidl_runtime_rs::Message for Duration { |
| 67 | + type RmwMsg = Self; |
| 68 | + fn into_rmw_message( |
| 69 | + msg_cow: std::borrow::Cow<'_, Self>, |
| 70 | + ) -> std::borrow::Cow<'_, Self::RmwMsg> { |
| 71 | + msg_cow |
| 72 | + } |
| 73 | + fn from_rmw_message(msg: Self::RmwMsg) -> Self { |
| 74 | + msg |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + impl rosidl_runtime_rs::RmwMessage for Duration |
| 79 | + where |
| 80 | + Self: Sized, |
| 81 | + { |
| 82 | + const TYPE_NAME: &'static str = "builtin_interfaces/msg/Duration"; |
| 83 | + fn get_type_support() -> *const std::os::raw::c_void { |
| 84 | + // SAFETY: No preconditions for this function. |
| 85 | + unsafe { |
| 86 | + rosidl_typesupport_c__get_message_type_support_handle__builtin_interfaces__msg__Duration() |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + #[link(name = "builtin_interfaces__rosidl_typesupport_c")] |
| 92 | + extern "C" { |
| 93 | + fn rosidl_typesupport_c__get_message_type_support_handle__builtin_interfaces__msg__Time( |
| 94 | + ) -> *const std::os::raw::c_void; |
| 95 | + } |
| 96 | + |
| 97 | + #[link(name = "builtin_interfaces__rosidl_generator_c")] |
| 98 | + extern "C" { |
| 99 | + fn builtin_interfaces__msg__Time__init(msg: *mut Time) -> bool; |
| 100 | + fn builtin_interfaces__msg__Time__Sequence__init( |
| 101 | + seq: *mut rosidl_runtime_rs::Sequence<Time>, |
| 102 | + size: usize, |
| 103 | + ) -> bool; |
| 104 | + fn builtin_interfaces__msg__Time__Sequence__fini( |
| 105 | + seq: *mut rosidl_runtime_rs::Sequence<Time>, |
| 106 | + ); |
| 107 | + fn builtin_interfaces__msg__Time__Sequence__copy( |
| 108 | + in_seq: &rosidl_runtime_rs::Sequence<Time>, |
| 109 | + out_seq: *mut rosidl_runtime_rs::Sequence<Time>, |
| 110 | + ) -> bool; |
| 111 | + } |
| 112 | + |
| 113 | + // Corresponds to builtin_interfaces__msg__Time |
| 114 | + #[repr(C)] |
| 115 | + #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
| 116 | + #[derive(Clone, Debug, PartialEq, PartialOrd)] |
| 117 | + pub struct Time { |
| 118 | + pub sec: i32, |
| 119 | + pub nanosec: u32, |
| 120 | + } |
| 121 | + |
| 122 | + impl Default for Time { |
| 123 | + fn default() -> Self { |
| 124 | + unsafe { |
| 125 | + let mut msg = std::mem::zeroed(); |
| 126 | + if !builtin_interfaces__msg__Time__init(&mut msg as *mut _) { |
| 127 | + panic!("Call to builtin_interfaces__msg__Time__init() failed"); |
| 128 | + } |
| 129 | + msg |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + impl rosidl_runtime_rs::SequenceAlloc for Time { |
| 135 | + fn sequence_init(seq: &mut rosidl_runtime_rs::Sequence<Self>, size: usize) -> bool { |
| 136 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 137 | + unsafe { builtin_interfaces__msg__Time__Sequence__init(seq as *mut _, size) } |
| 138 | + } |
| 139 | + fn sequence_fini(seq: &mut rosidl_runtime_rs::Sequence<Self>) { |
| 140 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 141 | + unsafe { builtin_interfaces__msg__Time__Sequence__fini(seq as *mut _) } |
| 142 | + } |
| 143 | + fn sequence_copy( |
| 144 | + in_seq: &rosidl_runtime_rs::Sequence<Self>, |
| 145 | + out_seq: &mut rosidl_runtime_rs::Sequence<Self>, |
| 146 | + ) -> bool { |
| 147 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 148 | + unsafe { builtin_interfaces__msg__Time__Sequence__copy(in_seq, out_seq as *mut _) } |
| 149 | + } |
| 150 | + } |
| 151 | + |
| 152 | + impl rosidl_runtime_rs::Message for Time { |
| 153 | + type RmwMsg = Self; |
| 154 | + fn into_rmw_message( |
| 155 | + msg_cow: std::borrow::Cow<'_, Self>, |
| 156 | + ) -> std::borrow::Cow<'_, Self::RmwMsg> { |
| 157 | + msg_cow |
| 158 | + } |
| 159 | + fn from_rmw_message(msg: Self::RmwMsg) -> Self { |
| 160 | + msg |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + impl rosidl_runtime_rs::RmwMessage for Time |
| 165 | + where |
| 166 | + Self: Sized, |
| 167 | + { |
| 168 | + const TYPE_NAME: &'static str = "builtin_interfaces/msg/Time"; |
| 169 | + fn get_type_support() -> *const std::os::raw::c_void { |
| 170 | + // SAFETY: No preconditions for this function. |
| 171 | + unsafe { |
| 172 | + rosidl_typesupport_c__get_message_type_support_handle__builtin_interfaces__msg__Time( |
| 173 | + ) |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | +} // mod rmw |
| 178 | + |
| 179 | +#[cfg(feature = "serde")] |
| 180 | +use serde::{Deserialize, Serialize}; |
| 181 | + |
| 182 | +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
| 183 | +#[derive(Clone, Debug, PartialEq, PartialOrd)] |
| 184 | +pub struct Duration { |
| 185 | + pub sec: i32, |
| 186 | + pub nanosec: u32, |
| 187 | +} |
| 188 | + |
| 189 | +impl Default for Duration { |
| 190 | + fn default() -> Self { |
| 191 | + <Self as rosidl_runtime_rs::Message>::from_rmw_message( |
| 192 | + crate::vendor::builtin_interfaces::msg::rmw::Duration::default(), |
| 193 | + ) |
| 194 | + } |
| 195 | +} |
| 196 | + |
| 197 | +impl rosidl_runtime_rs::Message for Duration { |
| 198 | + type RmwMsg = crate::vendor::builtin_interfaces::msg::rmw::Duration; |
| 199 | + |
| 200 | + fn into_rmw_message(msg_cow: std::borrow::Cow<'_, Self>) -> std::borrow::Cow<'_, Self::RmwMsg> { |
| 201 | + match msg_cow { |
| 202 | + std::borrow::Cow::Owned(msg) => std::borrow::Cow::Owned(Self::RmwMsg { |
| 203 | + sec: msg.sec, |
| 204 | + nanosec: msg.nanosec, |
| 205 | + }), |
| 206 | + std::borrow::Cow::Borrowed(msg) => std::borrow::Cow::Owned(Self::RmwMsg { |
| 207 | + sec: msg.sec, |
| 208 | + nanosec: msg.nanosec, |
| 209 | + }), |
| 210 | + } |
| 211 | + } |
| 212 | + |
| 213 | + fn from_rmw_message(msg: Self::RmwMsg) -> Self { |
| 214 | + Self { |
| 215 | + sec: msg.sec, |
| 216 | + nanosec: msg.nanosec, |
| 217 | + } |
| 218 | + } |
| 219 | +} |
| 220 | + |
| 221 | +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
| 222 | +#[derive(Clone, Debug, PartialEq, PartialOrd)] |
| 223 | +pub struct Time { |
| 224 | + pub sec: i32, |
| 225 | + pub nanosec: u32, |
| 226 | +} |
| 227 | + |
| 228 | +impl Default for Time { |
| 229 | + fn default() -> Self { |
| 230 | + <Self as rosidl_runtime_rs::Message>::from_rmw_message( |
| 231 | + crate::vendor::builtin_interfaces::msg::rmw::Time::default(), |
| 232 | + ) |
| 233 | + } |
| 234 | +} |
| 235 | + |
| 236 | +impl rosidl_runtime_rs::Message for Time { |
| 237 | + type RmwMsg = crate::vendor::builtin_interfaces::msg::rmw::Time; |
| 238 | + |
| 239 | + fn into_rmw_message(msg_cow: std::borrow::Cow<'_, Self>) -> std::borrow::Cow<'_, Self::RmwMsg> { |
| 240 | + match msg_cow { |
| 241 | + std::borrow::Cow::Owned(msg) => std::borrow::Cow::Owned(Self::RmwMsg { |
| 242 | + sec: msg.sec, |
| 243 | + nanosec: msg.nanosec, |
| 244 | + }), |
| 245 | + std::borrow::Cow::Borrowed(msg) => std::borrow::Cow::Owned(Self::RmwMsg { |
| 246 | + sec: msg.sec, |
| 247 | + nanosec: msg.nanosec, |
| 248 | + }), |
| 249 | + } |
| 250 | + } |
| 251 | + |
| 252 | + fn from_rmw_message(msg: Self::RmwMsg) -> Self { |
| 253 | + Self { |
| 254 | + sec: msg.sec, |
| 255 | + nanosec: msg.nanosec, |
| 256 | + } |
| 257 | + } |
| 258 | +} |
0 commit comments