safe_drive/msg/jazzy/common_interfaces/visualization_msgs/msg/
interactive_marker_feedback.rs

1// This file was automatically generated by ros2msg_to_rs (https://github.com/tier4/ros2msg_to_rs).
2use super::super::super::*;
3use super::*;
4use crate::msg::*;
5use crate::rcl;
6pub const INTERACTIVE_MAKER_FEEDBACK_KEEP_ALIVE: u8 = 0;
7pub const INTERACTIVE_MAKER_FEEDBACK_POSE_UPDATE: u8 = 1;
8pub const INTERACTIVE_MAKER_FEEDBACK_MENU_SELECT: u8 = 2;
9pub const INTERACTIVE_MAKER_FEEDBACK_BUTTON_CLICK: u8 = 3;
10pub const INTERACTIVE_MAKER_FEEDBACK_MOUSE_DOWN: u8 = 4;
11pub const INTERACTIVE_MAKER_FEEDBACK_MOUSE_UP: u8 = 5;
12
13extern "C" {
14    fn visualization_msgs__msg__InteractiveMarkerFeedback__init(
15        msg: *mut InteractiveMarkerFeedback,
16    ) -> bool;
17    fn visualization_msgs__msg__InteractiveMarkerFeedback__fini(
18        msg: *mut InteractiveMarkerFeedback,
19    );
20    fn visualization_msgs__msg__InteractiveMarkerFeedback__are_equal(
21        lhs: *const InteractiveMarkerFeedback,
22        rhs: *const InteractiveMarkerFeedback,
23    ) -> bool;
24    fn visualization_msgs__msg__InteractiveMarkerFeedback__Sequence__init(
25        msg: *mut InteractiveMarkerFeedbackSeqRaw,
26        size: usize,
27    ) -> bool;
28    fn visualization_msgs__msg__InteractiveMarkerFeedback__Sequence__fini(
29        msg: *mut InteractiveMarkerFeedbackSeqRaw,
30    );
31    fn visualization_msgs__msg__InteractiveMarkerFeedback__Sequence__are_equal(
32        lhs: *const InteractiveMarkerFeedbackSeqRaw,
33        rhs: *const InteractiveMarkerFeedbackSeqRaw,
34    ) -> bool;
35    fn rosidl_typesupport_c__get_message_type_support_handle__visualization_msgs__msg__InteractiveMarkerFeedback(
36    ) -> *const rcl::rosidl_message_type_support_t;
37}
38
39#[repr(C)]
40#[derive(Debug)]
41pub struct InteractiveMarkerFeedback {
42    pub header: std_msgs::msg::Header,
43    pub client_id: crate::msg::RosString<0>,
44    pub marker_name: crate::msg::RosString<0>,
45    pub control_name: crate::msg::RosString<0>,
46    pub event_type: u8,
47    pub pose: geometry_msgs::msg::Pose,
48    pub menu_entry_id: u32,
49    pub mouse_point: geometry_msgs::msg::Point,
50    pub mouse_point_valid: bool,
51}
52
53impl InteractiveMarkerFeedback {
54    pub fn new() -> Option<Self> {
55        let mut msg: Self = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
56        if unsafe { visualization_msgs__msg__InteractiveMarkerFeedback__init(&mut msg) } {
57            Some(msg)
58        } else {
59            None
60        }
61    }
62}
63
64impl Drop for InteractiveMarkerFeedback {
65    fn drop(&mut self) {
66        unsafe { visualization_msgs__msg__InteractiveMarkerFeedback__fini(self) };
67    }
68}
69
70#[repr(C)]
71#[derive(Debug)]
72struct InteractiveMarkerFeedbackSeqRaw {
73    data: *mut InteractiveMarkerFeedback,
74    size: size_t,
75    capacity: size_t,
76}
77
78/// Sequence of InteractiveMarkerFeedback.
79/// `N` is the maximum number of elements.
80/// If `N` is `0`, the size is unlimited.
81#[repr(C)]
82#[derive(Debug)]
83pub struct InteractiveMarkerFeedbackSeq<const N: usize> {
84    data: *mut InteractiveMarkerFeedback,
85    size: size_t,
86    capacity: size_t,
87}
88
89impl<const N: usize> InteractiveMarkerFeedbackSeq<N> {
90    /// Create a sequence of.
91    /// `N` represents the maximum number of elements.
92    /// If `N` is `0`, the sequence is unlimited.
93    pub fn new(size: usize) -> Option<Self> {
94        if N != 0 && size > N {
95            // the size exceeds in the maximum number
96            return None;
97        }
98
99        let mut msg: InteractiveMarkerFeedbackSeqRaw =
100            unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
101        if unsafe {
102            visualization_msgs__msg__InteractiveMarkerFeedback__Sequence__init(&mut msg, size)
103        } {
104            Some(Self {
105                data: msg.data,
106                size: msg.size,
107                capacity: msg.capacity,
108            })
109        } else {
110            None
111        }
112    }
113
114    pub fn null() -> Self {
115        let msg: InteractiveMarkerFeedbackSeqRaw =
116            unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
117        Self {
118            data: msg.data,
119            size: msg.size,
120            capacity: msg.capacity,
121        }
122    }
123
124    pub fn as_slice(&self) -> &[InteractiveMarkerFeedback] {
125        if self.data.is_null() {
126            &[]
127        } else {
128            let s = unsafe { std::slice::from_raw_parts(self.data, self.size as _) };
129            s
130        }
131    }
132
133    pub fn as_slice_mut(&mut self) -> &mut [InteractiveMarkerFeedback] {
134        if self.data.is_null() {
135            &mut []
136        } else {
137            let s = unsafe { std::slice::from_raw_parts_mut(self.data, self.size as _) };
138            s
139        }
140    }
141
142    pub fn iter(&self) -> std::slice::Iter<'_, InteractiveMarkerFeedback> {
143        self.as_slice().iter()
144    }
145
146    pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, InteractiveMarkerFeedback> {
147        self.as_slice_mut().iter_mut()
148    }
149
150    pub fn len(&self) -> usize {
151        self.as_slice().len()
152    }
153
154    pub fn is_empty(&self) -> bool {
155        self.len() == 0
156    }
157}
158
159impl<const N: usize> Drop for InteractiveMarkerFeedbackSeq<N> {
160    fn drop(&mut self) {
161        let mut msg = InteractiveMarkerFeedbackSeqRaw {
162            data: self.data,
163            size: self.size,
164            capacity: self.capacity,
165        };
166        unsafe { visualization_msgs__msg__InteractiveMarkerFeedback__Sequence__fini(&mut msg) };
167    }
168}
169
170unsafe impl<const N: usize> Send for InteractiveMarkerFeedbackSeq<N> {}
171unsafe impl<const N: usize> Sync for InteractiveMarkerFeedbackSeq<N> {}
172
173impl TypeSupport for InteractiveMarkerFeedback {
174    fn type_support() -> *const rcl::rosidl_message_type_support_t {
175        unsafe {
176            rosidl_typesupport_c__get_message_type_support_handle__visualization_msgs__msg__InteractiveMarkerFeedback()
177        }
178    }
179}
180
181impl PartialEq for InteractiveMarkerFeedback {
182    fn eq(&self, other: &Self) -> bool {
183        unsafe { visualization_msgs__msg__InteractiveMarkerFeedback__are_equal(self, other) }
184    }
185}
186
187impl<const N: usize> PartialEq for InteractiveMarkerFeedbackSeq<N> {
188    fn eq(&self, other: &Self) -> bool {
189        unsafe {
190            let msg1 = InteractiveMarkerFeedbackSeqRaw {
191                data: self.data,
192                size: self.size,
193                capacity: self.capacity,
194            };
195            let msg2 = InteractiveMarkerFeedbackSeqRaw {
196                data: other.data,
197                size: other.size,
198                capacity: other.capacity,
199            };
200            visualization_msgs__msg__InteractiveMarkerFeedback__Sequence__are_equal(&msg1, &msg2)
201        }
202    }
203}