safe_drive/msg/jazzy/common_interfaces/visualization_msgs/msg/
interactive_marker_pose.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;
6
7extern "C" {
8    fn visualization_msgs__msg__InteractiveMarkerPose__init(
9        msg: *mut InteractiveMarkerPose,
10    ) -> bool;
11    fn visualization_msgs__msg__InteractiveMarkerPose__fini(msg: *mut InteractiveMarkerPose);
12    fn visualization_msgs__msg__InteractiveMarkerPose__are_equal(
13        lhs: *const InteractiveMarkerPose,
14        rhs: *const InteractiveMarkerPose,
15    ) -> bool;
16    fn visualization_msgs__msg__InteractiveMarkerPose__Sequence__init(
17        msg: *mut InteractiveMarkerPoseSeqRaw,
18        size: usize,
19    ) -> bool;
20    fn visualization_msgs__msg__InteractiveMarkerPose__Sequence__fini(
21        msg: *mut InteractiveMarkerPoseSeqRaw,
22    );
23    fn visualization_msgs__msg__InteractiveMarkerPose__Sequence__are_equal(
24        lhs: *const InteractiveMarkerPoseSeqRaw,
25        rhs: *const InteractiveMarkerPoseSeqRaw,
26    ) -> bool;
27    fn rosidl_typesupport_c__get_message_type_support_handle__visualization_msgs__msg__InteractiveMarkerPose(
28    ) -> *const rcl::rosidl_message_type_support_t;
29}
30
31#[repr(C)]
32#[derive(Debug)]
33pub struct InteractiveMarkerPose {
34    pub header: std_msgs::msg::Header,
35    pub pose: geometry_msgs::msg::Pose,
36    pub name: crate::msg::RosString<0>,
37}
38
39impl InteractiveMarkerPose {
40    pub fn new() -> Option<Self> {
41        let mut msg: Self = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
42        if unsafe { visualization_msgs__msg__InteractiveMarkerPose__init(&mut msg) } {
43            Some(msg)
44        } else {
45            None
46        }
47    }
48}
49
50impl Drop for InteractiveMarkerPose {
51    fn drop(&mut self) {
52        unsafe { visualization_msgs__msg__InteractiveMarkerPose__fini(self) };
53    }
54}
55
56#[repr(C)]
57#[derive(Debug)]
58struct InteractiveMarkerPoseSeqRaw {
59    data: *mut InteractiveMarkerPose,
60    size: size_t,
61    capacity: size_t,
62}
63
64/// Sequence of InteractiveMarkerPose.
65/// `N` is the maximum number of elements.
66/// If `N` is `0`, the size is unlimited.
67#[repr(C)]
68#[derive(Debug)]
69pub struct InteractiveMarkerPoseSeq<const N: usize> {
70    data: *mut InteractiveMarkerPose,
71    size: size_t,
72    capacity: size_t,
73}
74
75impl<const N: usize> InteractiveMarkerPoseSeq<N> {
76    /// Create a sequence of.
77    /// `N` represents the maximum number of elements.
78    /// If `N` is `0`, the sequence is unlimited.
79    pub fn new(size: usize) -> Option<Self> {
80        if N != 0 && size > N {
81            // the size exceeds in the maximum number
82            return None;
83        }
84
85        let mut msg: InteractiveMarkerPoseSeqRaw =
86            unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
87        if unsafe { visualization_msgs__msg__InteractiveMarkerPose__Sequence__init(&mut msg, size) }
88        {
89            Some(Self {
90                data: msg.data,
91                size: msg.size,
92                capacity: msg.capacity,
93            })
94        } else {
95            None
96        }
97    }
98
99    pub fn null() -> Self {
100        let msg: InteractiveMarkerPoseSeqRaw =
101            unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
102        Self {
103            data: msg.data,
104            size: msg.size,
105            capacity: msg.capacity,
106        }
107    }
108
109    pub fn as_slice(&self) -> &[InteractiveMarkerPose] {
110        if self.data.is_null() {
111            &[]
112        } else {
113            let s = unsafe { std::slice::from_raw_parts(self.data, self.size as _) };
114            s
115        }
116    }
117
118    pub fn as_slice_mut(&mut self) -> &mut [InteractiveMarkerPose] {
119        if self.data.is_null() {
120            &mut []
121        } else {
122            let s = unsafe { std::slice::from_raw_parts_mut(self.data, self.size as _) };
123            s
124        }
125    }
126
127    pub fn iter(&self) -> std::slice::Iter<'_, InteractiveMarkerPose> {
128        self.as_slice().iter()
129    }
130
131    pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, InteractiveMarkerPose> {
132        self.as_slice_mut().iter_mut()
133    }
134
135    pub fn len(&self) -> usize {
136        self.as_slice().len()
137    }
138
139    pub fn is_empty(&self) -> bool {
140        self.len() == 0
141    }
142}
143
144impl<const N: usize> Drop for InteractiveMarkerPoseSeq<N> {
145    fn drop(&mut self) {
146        let mut msg = InteractiveMarkerPoseSeqRaw {
147            data: self.data,
148            size: self.size,
149            capacity: self.capacity,
150        };
151        unsafe { visualization_msgs__msg__InteractiveMarkerPose__Sequence__fini(&mut msg) };
152    }
153}
154
155unsafe impl<const N: usize> Send for InteractiveMarkerPoseSeq<N> {}
156unsafe impl<const N: usize> Sync for InteractiveMarkerPoseSeq<N> {}
157
158impl TypeSupport for InteractiveMarkerPose {
159    fn type_support() -> *const rcl::rosidl_message_type_support_t {
160        unsafe {
161            rosidl_typesupport_c__get_message_type_support_handle__visualization_msgs__msg__InteractiveMarkerPose()
162        }
163    }
164}
165
166impl PartialEq for InteractiveMarkerPose {
167    fn eq(&self, other: &Self) -> bool {
168        unsafe { visualization_msgs__msg__InteractiveMarkerPose__are_equal(self, other) }
169    }
170}
171
172impl<const N: usize> PartialEq for InteractiveMarkerPoseSeq<N> {
173    fn eq(&self, other: &Self) -> bool {
174        unsafe {
175            let msg1 = InteractiveMarkerPoseSeqRaw {
176                data: self.data,
177                size: self.size,
178                capacity: self.capacity,
179            };
180            let msg2 = InteractiveMarkerPoseSeqRaw {
181                data: other.data,
182                size: other.size,
183                capacity: other.capacity,
184            };
185            visualization_msgs__msg__InteractiveMarkerPose__Sequence__are_equal(&msg1, &msg2)
186        }
187    }
188}