rtps_rs/messages/
protocol_version.rs1use speedy::{Readable, Writable};
2
3#[derive(Copy, Clone, Debug, PartialOrd, PartialEq, Ord, Eq, Readable, Writable)]
4pub struct ProtocolVersion_t {
5 pub major: u8,
6 pub minor: u8,
7}
8
9impl ProtocolVersion_t {
10 pub const PROTOCOLVERSION: ProtocolVersion_t = ProtocolVersion_t::PROTOCOLVERSION_2_4;
11
12 pub const PROTOCOLVERSION_1_0: ProtocolVersion_t = ProtocolVersion_t { major: 1, minor: 0 };
13 pub const PROTOCOLVERSION_1_1: ProtocolVersion_t = ProtocolVersion_t { major: 1, minor: 1 };
14 pub const PROTOCOLVERSION_2_0: ProtocolVersion_t = ProtocolVersion_t { major: 2, minor: 0 };
15 pub const PROTOCOLVERSION_2_1: ProtocolVersion_t = ProtocolVersion_t { major: 2, minor: 1 };
16 pub const PROTOCOLVERSION_2_2: ProtocolVersion_t = ProtocolVersion_t { major: 2, minor: 2 };
17 pub const PROTOCOLVERSION_2_4: ProtocolVersion_t = ProtocolVersion_t { major: 2, minor: 4 };
18}
19
20impl Default for ProtocolVersion_t {
21 fn default() -> Self {
22 ProtocolVersion_t::PROTOCOLVERSION
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 serialization_test!( type = ProtocolVersion_t,
31 {
32 protocol_version,
33 ProtocolVersion_t::PROTOCOLVERSION,
34 le = [0x02, 0x04],
35 be = [0x02, 0x04]
36 },
37 {
38 protocol_version_default,
39 ProtocolVersion_t::default(),
40 le = [0x02, 0x04],
41 be = [0x02, 0x04]
42 },
43 {
44 protocol_version_1_0,
45 ProtocolVersion_t::PROTOCOLVERSION_1_0,
46 le = [0x01, 0x00],
47 be = [0x01, 0x00]
48 },
49 {
50 protocol_version_1_1,
51 ProtocolVersion_t::PROTOCOLVERSION_1_1,
52 le = [0x01, 0x01],
53 be = [0x01, 0x01]
54 },
55 {
56 protocol_version_2_0,
57 ProtocolVersion_t::PROTOCOLVERSION_2_0,
58 le = [0x02, 0x00],
59 be = [0x02, 0x00]
60 },
61 {
62 protocol_version_2_1,
63 ProtocolVersion_t::PROTOCOLVERSION_2_1,
64 le = [0x02, 0x01],
65 be = [0x02, 0x01]
66 },
67 {
68 protocol_version_2_2,
69 ProtocolVersion_t::PROTOCOLVERSION_2_2,
70 le = [0x02, 0x02],
71 be = [0x02, 0x02]
72 },
73 {
74 protocol_version_2_4,
75 ProtocolVersion_t::PROTOCOLVERSION_2_4,
76 le = [0x02, 0x04],
77 be = [0x02, 0x04]
78 });
79}