use super::super::super::*;
use super::*;
use crate::msg::*;
use crate::rcl;
extern "C" {
fn visualization_msgs__msg__InteractiveMarker__init(msg: *mut InteractiveMarker) -> bool;
fn visualization_msgs__msg__InteractiveMarker__fini(msg: *mut InteractiveMarker);
fn visualization_msgs__msg__InteractiveMarker__are_equal(
lhs: *const InteractiveMarker,
rhs: *const InteractiveMarker,
) -> bool;
fn visualization_msgs__msg__InteractiveMarker__Sequence__init(
msg: *mut InteractiveMarkerSeqRaw,
size: usize,
) -> bool;
fn visualization_msgs__msg__InteractiveMarker__Sequence__fini(
msg: *mut InteractiveMarkerSeqRaw,
);
fn visualization_msgs__msg__InteractiveMarker__Sequence__are_equal(
lhs: *const InteractiveMarkerSeqRaw,
rhs: *const InteractiveMarkerSeqRaw,
) -> bool;
fn rosidl_typesupport_c__get_message_type_support_handle__visualization_msgs__msg__InteractiveMarker(
) -> *const rcl::rosidl_message_type_support_t;
}
#[repr(C)]
#[derive(Debug)]
pub struct InteractiveMarker {
pub header: std_msgs::msg::Header,
pub pose: geometry_msgs::msg::Pose,
pub name: crate::msg::RosString<0>,
pub description: crate::msg::RosString<0>,
pub scale: f32,
pub menu_entries: MenuEntrySeq<0>,
pub controls: InteractiveMarkerControlSeq<0>,
}
impl InteractiveMarker {
pub fn new() -> Option<Self> {
let mut msg: Self = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
if unsafe { visualization_msgs__msg__InteractiveMarker__init(&mut msg) } {
Some(msg)
} else {
None
}
}
}
impl Drop for InteractiveMarker {
fn drop(&mut self) {
unsafe { visualization_msgs__msg__InteractiveMarker__fini(self) };
}
}
#[repr(C)]
#[derive(Debug)]
struct InteractiveMarkerSeqRaw {
data: *mut InteractiveMarker,
size: size_t,
capacity: size_t,
}
#[repr(C)]
#[derive(Debug)]
pub struct InteractiveMarkerSeq<const N: usize> {
data: *mut InteractiveMarker,
size: size_t,
capacity: size_t,
}
impl<const N: usize> InteractiveMarkerSeq<N> {
pub fn new(size: usize) -> Option<Self> {
if N != 0 && size > N {
return None;
}
let mut msg: InteractiveMarkerSeqRaw =
unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
if unsafe { visualization_msgs__msg__InteractiveMarker__Sequence__init(&mut msg, size) } {
Some(Self {
data: msg.data,
size: msg.size,
capacity: msg.capacity,
})
} else {
None
}
}
pub fn null() -> Self {
let msg: InteractiveMarkerSeqRaw = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
Self {
data: msg.data,
size: msg.size,
capacity: msg.capacity,
}
}
pub fn as_slice(&self) -> &[InteractiveMarker] {
if self.data.is_null() {
&[]
} else {
let s = unsafe { std::slice::from_raw_parts(self.data, self.size as _) };
s
}
}
pub fn as_slice_mut(&mut self) -> &mut [InteractiveMarker] {
if self.data.is_null() {
&mut []
} else {
let s = unsafe { std::slice::from_raw_parts_mut(self.data, self.size as _) };
s
}
}
pub fn iter(&self) -> std::slice::Iter<'_, InteractiveMarker> {
self.as_slice().iter()
}
pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, InteractiveMarker> {
self.as_slice_mut().iter_mut()
}
pub fn len(&self) -> usize {
self.as_slice().len()
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}
impl<const N: usize> Drop for InteractiveMarkerSeq<N> {
fn drop(&mut self) {
let mut msg = InteractiveMarkerSeqRaw {
data: self.data,
size: self.size,
capacity: self.capacity,
};
unsafe { visualization_msgs__msg__InteractiveMarker__Sequence__fini(&mut msg) };
}
}
unsafe impl<const N: usize> Send for InteractiveMarkerSeq<N> {}
unsafe impl<const N: usize> Sync for InteractiveMarkerSeq<N> {}
impl TypeSupport for InteractiveMarker {
fn type_support() -> *const rcl::rosidl_message_type_support_t {
unsafe {
rosidl_typesupport_c__get_message_type_support_handle__visualization_msgs__msg__InteractiveMarker()
}
}
}
impl PartialEq for InteractiveMarker {
fn eq(&self, other: &Self) -> bool {
unsafe { visualization_msgs__msg__InteractiveMarker__are_equal(self, other) }
}
}
impl<const N: usize> PartialEq for InteractiveMarkerSeq<N> {
fn eq(&self, other: &Self) -> bool {
unsafe {
let msg1 = InteractiveMarkerSeqRaw {
data: self.data,
size: self.size,
capacity: self.capacity,
};
let msg2 = InteractiveMarkerSeqRaw {
data: other.data,
size: other.size,
capacity: other.capacity,
};
visualization_msgs__msg__InteractiveMarker__Sequence__are_equal(&msg1, &msg2)
}
}
}