|
| 1 | +pub mod rmw { |
| 2 | + #[cfg(feature = "serde")] |
| 3 | + use serde::{Deserialize, Serialize}; |
| 4 | + |
| 5 | + #[link(name = "rosgraph_msgs__rosidl_typesupport_c")] |
| 6 | + extern "C" { |
| 7 | + fn rosidl_typesupport_c__get_message_type_support_handle__rosgraph_msgs__msg__Clock( |
| 8 | + ) -> *const std::os::raw::c_void; |
| 9 | + } |
| 10 | + |
| 11 | + #[link(name = "rosgraph_msgs__rosidl_generator_c")] |
| 12 | + extern "C" { |
| 13 | + fn rosgraph_msgs__msg__Clock__init(msg: *mut Clock) -> bool; |
| 14 | + fn rosgraph_msgs__msg__Clock__Sequence__init( |
| 15 | + seq: *mut rosidl_runtime_rs::Sequence<Clock>, |
| 16 | + size: usize, |
| 17 | + ) -> bool; |
| 18 | + fn rosgraph_msgs__msg__Clock__Sequence__fini(seq: *mut rosidl_runtime_rs::Sequence<Clock>); |
| 19 | + fn rosgraph_msgs__msg__Clock__Sequence__copy( |
| 20 | + in_seq: &rosidl_runtime_rs::Sequence<Clock>, |
| 21 | + out_seq: *mut rosidl_runtime_rs::Sequence<Clock>, |
| 22 | + ) -> bool; |
| 23 | + } |
| 24 | + |
| 25 | + // Corresponds to rosgraph_msgs__msg__Clock |
| 26 | + #[repr(C)] |
| 27 | + #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
| 28 | + #[derive(Clone, Debug, PartialEq, PartialOrd)] |
| 29 | + pub struct Clock { |
| 30 | + pub clock: crate::vendor::builtin_interfaces::msg::rmw::Time, |
| 31 | + } |
| 32 | + |
| 33 | + impl Default for Clock { |
| 34 | + fn default() -> Self { |
| 35 | + unsafe { |
| 36 | + let mut msg = std::mem::zeroed(); |
| 37 | + if !rosgraph_msgs__msg__Clock__init(&mut msg as *mut _) { |
| 38 | + panic!("Call to rosgraph_msgs__msg__Clock__init() failed"); |
| 39 | + } |
| 40 | + msg |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + impl rosidl_runtime_rs::SequenceAlloc for Clock { |
| 46 | + fn sequence_init(seq: &mut rosidl_runtime_rs::Sequence<Self>, size: usize) -> bool { |
| 47 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 48 | + unsafe { rosgraph_msgs__msg__Clock__Sequence__init(seq as *mut _, size) } |
| 49 | + } |
| 50 | + fn sequence_fini(seq: &mut rosidl_runtime_rs::Sequence<Self>) { |
| 51 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 52 | + unsafe { rosgraph_msgs__msg__Clock__Sequence__fini(seq as *mut _) } |
| 53 | + } |
| 54 | + fn sequence_copy( |
| 55 | + in_seq: &rosidl_runtime_rs::Sequence<Self>, |
| 56 | + out_seq: &mut rosidl_runtime_rs::Sequence<Self>, |
| 57 | + ) -> bool { |
| 58 | + // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized. |
| 59 | + unsafe { rosgraph_msgs__msg__Clock__Sequence__copy(in_seq, out_seq as *mut _) } |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + impl rosidl_runtime_rs::Message for Clock { |
| 64 | + type RmwMsg = Self; |
| 65 | + fn into_rmw_message( |
| 66 | + msg_cow: std::borrow::Cow<'_, Self>, |
| 67 | + ) -> std::borrow::Cow<'_, Self::RmwMsg> { |
| 68 | + msg_cow |
| 69 | + } |
| 70 | + fn from_rmw_message(msg: Self::RmwMsg) -> Self { |
| 71 | + msg |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + impl rosidl_runtime_rs::RmwMessage for Clock |
| 76 | + where |
| 77 | + Self: Sized, |
| 78 | + { |
| 79 | + const TYPE_NAME: &'static str = "rosgraph_msgs/msg/Clock"; |
| 80 | + fn get_type_support() -> *const std::os::raw::c_void { |
| 81 | + // SAFETY: No preconditions for this function. |
| 82 | + unsafe { |
| 83 | + rosidl_typesupport_c__get_message_type_support_handle__rosgraph_msgs__msg__Clock() |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | +} // mod rmw |
| 88 | + |
| 89 | +#[cfg(feature = "serde")] |
| 90 | +use serde::{Deserialize, Serialize}; |
| 91 | + |
| 92 | +#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
| 93 | +#[derive(Clone, Debug, PartialEq, PartialOrd)] |
| 94 | +pub struct Clock { |
| 95 | + pub clock: crate::vendor::builtin_interfaces::msg::Time, |
| 96 | +} |
| 97 | + |
| 98 | +impl Default for Clock { |
| 99 | + fn default() -> Self { |
| 100 | + <Self as rosidl_runtime_rs::Message>::from_rmw_message( |
| 101 | + crate::vendor::rosgraph_msgs::msg::rmw::Clock::default(), |
| 102 | + ) |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +impl rosidl_runtime_rs::Message for Clock { |
| 107 | + type RmwMsg = crate::vendor::rosgraph_msgs::msg::rmw::Clock; |
| 108 | + |
| 109 | + fn into_rmw_message(msg_cow: std::borrow::Cow<'_, Self>) -> std::borrow::Cow<'_, Self::RmwMsg> { |
| 110 | + match msg_cow { |
| 111 | + std::borrow::Cow::Owned(msg) => std::borrow::Cow::Owned(Self::RmwMsg { |
| 112 | + clock: crate::vendor::builtin_interfaces::msg::Time::into_rmw_message( |
| 113 | + std::borrow::Cow::Owned(msg.clock), |
| 114 | + ) |
| 115 | + .into_owned(), |
| 116 | + }), |
| 117 | + std::borrow::Cow::Borrowed(msg) => std::borrow::Cow::Owned(Self::RmwMsg { |
| 118 | + clock: crate::vendor::builtin_interfaces::msg::Time::into_rmw_message( |
| 119 | + std::borrow::Cow::Borrowed(&msg.clock), |
| 120 | + ) |
| 121 | + .into_owned(), |
| 122 | + }), |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + fn from_rmw_message(msg: Self::RmwMsg) -> Self { |
| 127 | + Self { |
| 128 | + clock: crate::vendor::builtin_interfaces::msg::Time::from_rmw_message(msg.clock), |
| 129 | + } |
| 130 | + } |
| 131 | +} |
0 commit comments