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