rtps_rs/structure/
guid.rs1use crate::structure::entity_id::EntityId_t;
2use crate::structure::guid_prefix::GuidPrefix_t;
3use speedy::{Readable, Writable};
4
5#[derive(Copy, Clone, Debug, Default, PartialOrd, PartialEq, Ord, Eq, Readable, Writable)]
6pub struct GUID_t {
7 pub guidPrefix: GuidPrefix_t,
8 pub entityId: EntityId_t,
9}
10
11impl GUID_t {
12 pub const GUID_UNKNOWN: GUID_t = GUID_t {
13 guidPrefix: GuidPrefix_t::GUIDPREFIX_UNKNOWN,
14 entityId: EntityId_t::ENTITYID_UNKNOWN,
15 };
16}
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21
22 #[test]
23 fn guid_unknown_is_a_combination_of_unknown_members() {
24 assert_eq!(
25 GUID_t {
26 entityId: EntityId_t::ENTITYID_UNKNOWN,
27 guidPrefix: GuidPrefix_t::GUIDPREFIX_UNKNOWN
28 },
29 GUID_t::GUID_UNKNOWN
30 );
31 }
32
33 serialization_test!( type = GUID_t,
34 {
35 guid_unknown,
36 GUID_t::GUID_UNKNOWN,
37 le = [0x00; 16],
38 be = [0x00; 16]
39 },
40 {
41 guid_default,
42 GUID_t::default(),
43 le = [0x00; 16],
44 be = [0x00; 16]
45 },
46 {
47 guid_entity_id_on_the_last_position,
48 GUID_t {
49 entityId: EntityId_t::ENTITYID_PARTICIPANT,
50 ..Default::default()
51 },
52 le = [0x00, 0x00, 0x00, 0x00,
53 0x00, 0x00, 0x00, 0x00,
54 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x01, 0xC1],
56 be = [0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x01, 0xC1]
60 }
61 );
62}