rustdds/messages/submessages/
heartbeat_frag.rs1use speedy::{Readable, Writable};
2
3use crate::structure::{
4 guid::EntityId,
5 sequence_number::{FragmentNumber, SequenceNumber},
6};
7use super::submessage::HasEntityIds;
8
9#[derive(Debug, PartialEq, Eq, Clone, Readable, Writable)]
16pub struct HeartbeatFrag {
17 pub reader_id: EntityId,
21
22 pub writer_id: EntityId,
24
25 pub writer_sn: SequenceNumber,
28
29 pub last_fragment_num: FragmentNumber,
32
33 pub count: i32,
38}
39
40impl HasEntityIds for HeartbeatFrag {
41 fn receiver_entity_id(&self) -> EntityId {
42 self.reader_id
43 }
44 fn sender_entity_id(&self) -> EntityId {
45 self.writer_id
46 }
47}
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 serialization_test!( type = HeartbeatFrag,
54 {
55 heartbeat_frag,
56 HeartbeatFrag {
57 reader_id: EntityId::SEDP_BUILTIN_PUBLICATIONS_READER,
58 writer_id: EntityId::SEDP_BUILTIN_PUBLICATIONS_WRITER,
59 writer_sn: SequenceNumber::from(42),
60 last_fragment_num: FragmentNumber::from(99_u32),
61 count: 6,
62 },
63 le = [0x00, 0x00, 0x03, 0xC7,
64 0x00, 0x00, 0x03, 0xC2,
65 0x00, 0x00, 0x00, 0x00,
66 0x2A, 0x00, 0x00, 0x00,
67 0x63, 0x00, 0x00, 0x00,
68 0x06, 0x00, 0x00, 0x00],
69 be = [0x00, 0x00, 0x03, 0xC7,
70 0x00, 0x00, 0x03, 0xC2,
71 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x2A,
73 0x00, 0x00, 0x00, 0x63,
74 0x00, 0x00, 0x00, 0x06]
75 });
76}