cu_ros_payloads/
std_msgs.rs1use serde::{Deserialize, Serialize};
2
3use crate::RosMsgAdapter;
4
5#[derive(Clone, Debug, Serialize, Deserialize)]
7pub struct Int8 {
8 pub data: i8,
9}
10
11impl RosMsgAdapter<'static> for i8 {
12 type Output = Int8;
13
14 fn namespace() -> &'static str {
15 "std_msgs"
16 }
17
18 fn type_hash() -> &'static str {
19 "RIHS01_26525065a403d972cb672f0777e333f0c799ad444ae5fcd79e43d1e73bd0f440"
20 }
21}
22
23impl From<&i8> for Int8 {
24 fn from(value: &i8) -> Self {
25 Self { data: *value }
26 }
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn test_adapter_type_info() {
35 let x: i8 = 42;
36 let (msg, _) = x.convert();
37 assert_eq!(msg.data, 42);
38 assert_eq!(<i8 as RosMsgAdapter>::namespace(), "std_msgs");
39 assert_eq!(<i8 as RosMsgAdapter>::type_name(), "Int8");
40 }
41
42 #[test]
43 #[cfg(feature = "humble")]
44 fn test_humble() {
45 let x: i8 = 42;
46 let (_, hash) = x.convert();
47 assert_eq!(hash, "TypeHashNotSupported");
48 }
49
50 #[test]
51 #[cfg(not(feature = "humble"))]
52 fn test_not_humble() {
53 let x: i8 = 42;
54 let (_, hash) = x.convert();
55 assert_eq!(
56 hash,
57 "RIHS01_26525065a403d972cb672f0777e333f0c799ad444ae5fcd79e43d1e73bd0f440"
58 );
59 }
60}