1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![allow(dead_code)]
#![allow(deref_nullptr)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
// Added to avoid clippy complaining about u128 types not being FFI safe
// Caused by https://github.com/ros2/ros2/issues/1374 in iron and newer
// See https://github.com/ros2-rust/ros2_rust/issues/320
#![allow(improper_ctypes)]
#![allow(improper_ctypes_definitions)]
#![allow(clippy::all)]
#![allow(missing_docs)]
cfg_if::cfg_if! {
if #[cfg(ros_distro="humble")] {
include!(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/rcl_bindings_generated_humble.rs",
)
);
} else if #[cfg(ros_distro="jazzy")] {
include!(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/rcl_bindings_generated_jazzy.rs",
)
);
} else if #[cfg(ros_distro="kilted")] {
include!(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/rcl_bindings_generated_kilted.rs",
)
);
} else if #[cfg(ros_distro="rolling")] {
include!(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/rcl_bindings_generated_rolling.rs",
)
);
} else {
panic!("Unsupported ROS distribution");
}
}
pub const RMW_GID_STORAGE_SIZE: usize = rmw_gid_storage_size_constant;
pub const RCL_ACTION_UUID_SIZE: usize = rcl_action_uuid_size_constant;
/// Wrapper around [`std::slice::from_raw_parts`] that accommodates the rcl
/// convention of providing a null pointer to represent empty arrays. This
/// violates the safety requirements of [`std::slice::from_raw_parts`].
///
/// # Safety
///
/// Behavior is undefined in all the same scenarios as [`slice::from_raw_parts`]
/// (see its safety section) except that null pointers are allowed and will
/// return a slice to an empty array.
pub(crate) unsafe fn rcl_from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
if data.is_null() {
&[]
} else {
// SAFETY: The user of this function is instructed to abide by all the
// safety requirements of slice::from_raw_parts except for null pointer
// values, which are checked above.
unsafe { std::slice::from_raw_parts(data, len) }
}
}