rtps_parser/lib.rs
1use std::time::Duration as StdDuration;
2
3
4pub mod rtps;
5pub mod parameter_id_values;
6
7pub type Duration = StdDuration;
8
9#[cfg(test)]
10mod integration_test {
11 use std::sync::Arc;
12
13 use crate::rtps::messages::overall_structure::RtpsMessageRead;
14
15
16 #[test]
17 fn test_example_read() {
18 #[rustfmt::skip]
19 let data = Arc::new([
20 b'R', b'T', b'P', b'S', // Protocol
21 2, 3, 9, 8, // ProtocolVersion | VendorId
22 3, 3, 3, 3, // GuidPrefix
23 3, 3, 3, 3, // GuidPrefix
24 3, 3, 3, 3, // GuidPrefix
25 0x15, 0b_0000_0011, 40, 0, // Submessage header
26 0, 0, 16, 0, // extraFlags, octetsToInlineQos
27 1, 2, 3, 4, // readerId: value[4]
28 6, 7, 8, 9, // writerId: value[4]
29 0, 0, 0, 0, // writerSN: high
30 5, 0, 0, 0, // writerSN: low
31 6, 0, 4, 0, // inlineQos: parameterId_1, length_1
32 10, 11, 12, 13, // inlineQos: value_1[length_1]
33 7, 0, 4, 0, // inlineQos: parameterId_2, length_2
34 20, 21, 22, 23, // inlineQos: value_2[length_2]
35 1, 0, 1, 0, // inlineQos: Sentinel
36 0x07, 0b_0000_0101, 28, 0, // Submessage header
37 1, 2, 3, 4, // readerId: value[4]
38 6, 7, 8, 9, // writerId: value[4]
39 0, 0, 0, 0, // firstSN: SequenceNumber: high
40 5, 0, 0, 0, // firstSN: SequenceNumber: low
41 0, 0, 0, 0, // lastSN: SequenceNumberSet: high
42 7, 0, 0, 0, // lastSN: SequenceNumberSet: low
43 2, 0, 0, 0, // count: Count: value (long)
44 ]);
45 let msg = RtpsMessageRead::new(data);
46 println!("Received {} submessages", msg.submessages().len());
47 }
48}