rtps_parser/rtps/
discovery_types.rs

1// This file implements the types that appear in the built-in topic messages
2// using the mapping described in 9.3.2 Mapping of the Types that Appear Within Submessages or Built-in Topic Data
3
4#[derive(PartialEq, Eq, Debug, Clone, Copy)]
5pub struct BuiltinEndpointSet(pub u32);
6
7impl Default for BuiltinEndpointSet {
8    fn default() -> Self {
9        Self(
10            Self::BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER
11                | Self::BUILTIN_ENDPOINT_PARTICIPANT_DETECTOR
12                | Self::BUILTIN_ENDPOINT_PUBLICATIONS_ANNOUNCER
13                | Self::BUILTIN_ENDPOINT_PUBLICATIONS_DETECTOR
14                | Self::BUILTIN_ENDPOINT_SUBSCRIPTIONS_ANNOUNCER
15                | Self::BUILTIN_ENDPOINT_SUBSCRIPTIONS_DETECTOR
16                | Self::BUILTIN_ENDPOINT_TOPICS_ANNOUNCER
17                | Self::BUILTIN_ENDPOINT_TOPICS_DETECTOR,
18        )
19    }
20}
21
22impl BuiltinEndpointSet {
23    pub const BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER: u32 = 1 << 0;
24    pub const BUILTIN_ENDPOINT_PARTICIPANT_DETECTOR: u32 = 1 << 1;
25    pub const BUILTIN_ENDPOINT_PUBLICATIONS_ANNOUNCER: u32 = 1 << 2;
26    pub const BUILTIN_ENDPOINT_PUBLICATIONS_DETECTOR: u32 = 1 << 3;
27    pub const BUILTIN_ENDPOINT_SUBSCRIPTIONS_ANNOUNCER: u32 = 1 << 4;
28    pub const BUILTIN_ENDPOINT_SUBSCRIPTIONS_DETECTOR: u32 = 1 << 5;
29
30    /*
31    The following have been deprecated in version 2.4 of the
32    specification. These bits should not be used by versions of the
33    protocol equal to or newer than the deprecated version unless
34    they are used with the same meaning as in versions prior to the
35    deprecated version.
36    @position(6) DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_ANNOUNCER,
37    @position(7) DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_DETECTOR,
38    @position(8) DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_ANNOUNCER,
39    @position(9) DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_DETECTOR,
40    */
41
42    pub const _BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER: u32 = 1 << 10;
43    pub const _BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_READER: u32 = 1 << 11;
44
45    /*
46    Bits 12-15 have been reserved by the DDS-Xtypes 1.2 Specification
47    and future revisions thereof.
48    Bits 16-27 have been reserved by the DDS-Security 1.1 Specification
49    and future revisions thereof.
50    */
51
52    pub const BUILTIN_ENDPOINT_TOPICS_ANNOUNCER: u32 = 1 << 28;
53    pub const BUILTIN_ENDPOINT_TOPICS_DETECTOR: u32 = 1 << 29;
54
55    #[allow(dead_code)]
56    pub fn new(value: u32) -> Self {
57        Self(value)
58    }
59
60    pub fn has(&self, endpoint: u32) -> bool {
61        (self.0 & endpoint) == endpoint
62    }
63}
64
65#[derive(PartialEq, Eq, Debug, Default, Clone, Copy)]
66pub struct BuiltinEndpointQos(pub u32);
67
68impl BuiltinEndpointQos {
69    #[allow(dead_code)]
70    pub const BEST_EFFORT_PARTICIPANT_MESSAGE_DATA_READER: u32 = 1 << 29;
71
72    #[allow(dead_code)]
73    pub fn new(value: u32) -> Self {
74        Self(value)
75    }
76
77    #[allow(dead_code)]
78    pub fn has(&self, endpoint: u32) -> bool {
79        (self.0 & endpoint) == endpoint
80    }
81}