dust_dds 0.15.0

Data Distribution Service (DDS) implementation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
use super::infrastructure::qos_policy::{
    DataRepresentationQosPolicy, DeadlineQosPolicy, DestinationOrderQosPolicy, DurabilityQosPolicy,
    GroupDataQosPolicy, HistoryQosPolicy, LatencyBudgetQosPolicy, LifespanQosPolicy,
    LivelinessQosPolicy, OwnershipQosPolicy, OwnershipStrengthQosPolicy, PartitionQosPolicy,
    PresentationQosPolicy, ReliabilityQosPolicy, ResourceLimitsQosPolicy, TimeBasedFilterQosPolicy,
    TopicDataQosPolicy, TransportPriorityQosPolicy, UserDataQosPolicy,
};
use crate::{
    dcps::data_representation_builtin_endpoints::parameter_id_values::{
        PID_DATA_REPRESENTATION, PID_DEADLINE, PID_DESTINATION_ORDER, PID_DURABILITY,
        PID_ENDPOINT_GUID, PID_GROUP_DATA, PID_HISTORY, PID_LATENCY_BUDGET, PID_LIFESPAN,
        PID_LIVELINESS, PID_OWNERSHIP, PID_OWNERSHIP_STRENGTH, PID_PARTICIPANT_GUID, PID_PARTITION,
        PID_PRESENTATION, PID_RELIABILITY, PID_RESOURCE_LIMITS, PID_TIME_BASED_FILTER,
        PID_TOPIC_DATA, PID_TOPIC_NAME, PID_TRANSPORT_PRIORITY, PID_TYPE_NAME, PID_USER_DATA,
    },
    infrastructure::{
        qos_policy::{
            DEFAULT_RELIABILITY_QOS_POLICY_DATA_READER_AND_TOPICS,
            DEFAULT_RELIABILITY_QOS_POLICY_DATA_WRITER,
        },
        type_support::TypeSupport,
    },
};
use alloc::string::String;

/// Topic name of the built-in publication discovery topic
pub const DCPS_PUBLICATION: &str = "DCPSPublication";

/// Topic name of the built-in subscription discovery topic
pub const DCPS_SUBSCRIPTION: &str = "DCPSSubscription";

/// Topic name of the built-in topic discovery topic
pub const DCPS_TOPIC: &str = "DCPSTopic";

/// Topic name of the built-in participant discovery topic
pub const DCPS_PARTICIPANT: &str = "DCPSParticipant";

/// Structure representing the instance handle (or key) of an entity.
#[derive(Debug, PartialEq, Eq, Clone, Default, TypeSupport)]
#[dust_dds(extensibility = "final", nested)]
pub struct BuiltInTopicKey {
    /// InstanceHandle value as an array of 16 octets.
    pub value: [u8; 16], // Originally in the DDS idl [i32;3]
}

/// Structure representing a discovered [`DomainParticipant`](crate::domain::domain_participant::DomainParticipant).
#[derive(Debug, PartialEq, Eq, Clone, TypeSupport)]
#[dust_dds(extensibility = "mutable")]
pub struct ParticipantBuiltinTopicData {
    #[dust_dds(id=PID_PARTICIPANT_GUID as u32, key)]
    pub(crate) key: BuiltInTopicKey,
    #[dust_dds(id=PID_USER_DATA as u32, optional)]
    pub(crate) user_data: UserDataQosPolicy,
}

impl ParticipantBuiltinTopicData {
    /// Get the key value of the discovered participant.
    pub fn key(&self) -> &BuiltInTopicKey {
        &self.key
    }

    /// Get the user data value of the discovered participant.
    pub fn user_data(&self) -> &UserDataQosPolicy {
        &self.user_data
    }
}

/// Structure representing a discovered [`Topic`](crate::topic_definition::topic::Topic).
#[derive(Debug, PartialEq, Eq, Clone, TypeSupport)]
#[dust_dds(extensibility = "mutable")]
pub struct TopicBuiltinTopicData {
    #[dust_dds(id=PID_ENDPOINT_GUID as u32, key)]
    pub(crate) key: BuiltInTopicKey,
    #[dust_dds(id=PID_TOPIC_NAME as u32)]
    pub(crate) name: String,
    #[dust_dds(id=PID_TYPE_NAME as u32)]
    pub(crate) type_name: String,
    #[dust_dds(id=PID_DURABILITY as u32, optional)]
    pub(crate) durability: DurabilityQosPolicy,
    #[dust_dds(id=PID_DEADLINE as u32, optional)]
    pub(crate) deadline: DeadlineQosPolicy,
    #[dust_dds(id=PID_LATENCY_BUDGET as u32, optional)]
    pub(crate) latency_budget: LatencyBudgetQosPolicy,
    #[dust_dds(id=PID_LIVELINESS as u32, optional)]
    pub(crate) liveliness: LivelinessQosPolicy,
    #[dust_dds(id=PID_RELIABILITY as u32, optional, default_value=DEFAULT_RELIABILITY_QOS_POLICY_DATA_READER_AND_TOPICS)]
    pub(crate) reliability: ReliabilityQosPolicy,
    #[dust_dds(id=PID_TRANSPORT_PRIORITY as u32, optional)]
    pub(crate) transport_priority: TransportPriorityQosPolicy,
    #[dust_dds(id=PID_LIFESPAN as u32, optional)]
    pub(crate) lifespan: LifespanQosPolicy,
    #[dust_dds(id=PID_DESTINATION_ORDER as u32, optional)]
    pub(crate) destination_order: DestinationOrderQosPolicy,
    #[dust_dds(id=PID_HISTORY as u32, optional)]
    pub(crate) history: HistoryQosPolicy,
    #[dust_dds(id=PID_RESOURCE_LIMITS as u32, optional)]
    pub(crate) resource_limits: ResourceLimitsQosPolicy,
    #[dust_dds(id=PID_OWNERSHIP as u32, optional)]
    pub(crate) ownership: OwnershipQosPolicy,
    #[dust_dds(id=PID_TOPIC_DATA as u32, optional)]
    pub(crate) topic_data: TopicDataQosPolicy,
    #[dust_dds(id=PID_DATA_REPRESENTATION as u32, optional)]
    pub(crate) representation: DataRepresentationQosPolicy,
}

impl TopicBuiltinTopicData {
    /// Get the key value of the discovered topic.
    pub fn key(&self) -> &BuiltInTopicKey {
        &self.key
    }

    /// Get the name of the discovered topic.
    pub fn name(&self) -> &str {
        &self.name
    }

    /// Get the type name of the discovered topic.
    pub fn get_type_name(&self) -> &str {
        &self.type_name
    }

    /// Get the durability QoS policy of the discovered topic.
    pub fn durability(&self) -> &DurabilityQosPolicy {
        &self.durability
    }

    /// Get the deadline QoS policy of the discovered topic.
    pub fn deadline(&self) -> &DeadlineQosPolicy {
        &self.deadline
    }

    /// Get the latency budget QoS policy of the discovered topic.
    pub fn latency_budget(&self) -> &LatencyBudgetQosPolicy {
        &self.latency_budget
    }

    /// Get the liveliness QoS policy of the discovered topic.
    pub fn liveliness(&self) -> &LivelinessQosPolicy {
        &self.liveliness
    }

    /// Get the reliability QoS policy of the discovered topic.
    pub fn reliability(&self) -> &ReliabilityQosPolicy {
        &self.reliability
    }

    /// Get the transport priority QoS policy of the discovered topic.
    pub fn transport_priority(&self) -> &TransportPriorityQosPolicy {
        &self.transport_priority
    }

    /// Get the lifespan QoS policy of the discovered topic.
    pub fn lifespan(&self) -> &LifespanQosPolicy {
        &self.lifespan
    }

    /// Get the destination order QoS policy of the discovered topic.
    pub fn destination_order(&self) -> &DestinationOrderQosPolicy {
        &self.destination_order
    }

    /// Get the history QoS policy of the discovered topic.
    pub fn history(&self) -> &HistoryQosPolicy {
        &self.history
    }

    /// Get the resource limits QoS policy of the discovered topic.
    pub fn resource_limits(&self) -> &ResourceLimitsQosPolicy {
        &self.resource_limits
    }

    /// Get the ownership QoS policy of the discovered topic.
    pub fn ownership(&self) -> &OwnershipQosPolicy {
        &self.ownership
    }

    /// Get the topic data QoS policy of the discovered topic.
    pub fn topic_data(&self) -> &TopicDataQosPolicy {
        &self.topic_data
    }

    /// Get the data representation QoS policy of the discovered topic.
    pub fn representation(&self) -> &DataRepresentationQosPolicy {
        &self.representation
    }
}

/// Structure representing a discovered [`DataWriter`](crate::publication::data_writer::DataWriter).
#[derive(Debug, PartialEq, Eq, Clone, TypeSupport)]
#[dust_dds(extensibility = "mutable")]
pub struct PublicationBuiltinTopicData {
    #[dust_dds(id=PID_ENDPOINT_GUID as u32, key)]
    pub(crate) key: BuiltInTopicKey,
    #[dust_dds(id=PID_PARTICIPANT_GUID as u32, key)]
    pub(crate) participant_key: BuiltInTopicKey,
    #[dust_dds(id=PID_TOPIC_NAME as u32)]
    pub(crate) topic_name: String,
    #[dust_dds(id=PID_TYPE_NAME as u32)]
    pub(crate) type_name: String,
    #[dust_dds(id=PID_DURABILITY as u32, optional)]
    pub(crate) durability: DurabilityQosPolicy,
    #[dust_dds(id=PID_DEADLINE as u32, optional)]
    pub(crate) deadline: DeadlineQosPolicy,
    #[dust_dds(id=PID_LATENCY_BUDGET as u32, optional)]
    pub(crate) latency_budget: LatencyBudgetQosPolicy,
    #[dust_dds(id=PID_LIVELINESS as u32, optional)]
    pub(crate) liveliness: LivelinessQosPolicy,
    #[dust_dds(id=PID_RELIABILITY as u32, optional, default_value=DEFAULT_RELIABILITY_QOS_POLICY_DATA_WRITER)]
    pub(crate) reliability: ReliabilityQosPolicy,
    #[dust_dds(id=PID_LIFESPAN as u32, optional)]
    pub(crate) lifespan: LifespanQosPolicy,
    #[dust_dds(id=PID_USER_DATA as u32, optional)]
    pub(crate) user_data: UserDataQosPolicy,
    #[dust_dds(id=PID_OWNERSHIP as u32, optional)]
    pub(crate) ownership: OwnershipQosPolicy,
    #[dust_dds(id=PID_OWNERSHIP_STRENGTH as u32, optional)]
    pub(crate) ownership_strength: OwnershipStrengthQosPolicy,
    #[dust_dds(id=PID_DESTINATION_ORDER as u32, optional)]
    pub(crate) destination_order: DestinationOrderQosPolicy,
    #[dust_dds(id=PID_PRESENTATION as u32, optional)]
    pub(crate) presentation: PresentationQosPolicy,
    #[dust_dds(id=PID_PARTITION as u32, optional)]
    pub(crate) partition: PartitionQosPolicy,
    #[dust_dds(id=PID_TOPIC_DATA as u32, optional)]
    pub(crate) topic_data: TopicDataQosPolicy,
    #[dust_dds(id=PID_GROUP_DATA as u32, optional)]
    pub(crate) group_data: GroupDataQosPolicy,
    #[dust_dds(id=PID_DATA_REPRESENTATION as u32, optional)]
    pub(crate) representation: DataRepresentationQosPolicy,
}

impl PublicationBuiltinTopicData {
    /// Get the key value of the discovered writer.
    pub fn key(&self) -> &BuiltInTopicKey {
        &self.key
    }

    /// Get the key value of the parent participant of the discovered writer.
    pub fn participant_key(&self) -> &BuiltInTopicKey {
        &self.participant_key
    }

    /// Get the name of the topic associated with the discovered writer.
    pub fn topic_name(&self) -> &str {
        &self.topic_name
    }

    /// Get the name of the type associated with the discovered writer.
    pub fn get_type_name(&self) -> &str {
        &self.type_name
    }

    /// Get the durability QoS policy of the discovered writer.
    pub fn durability(&self) -> &DurabilityQosPolicy {
        &self.durability
    }

    /// Get the deadline QoS policy of the discovered writer.
    pub fn deadline(&self) -> &DeadlineQosPolicy {
        &self.deadline
    }

    /// Get the latency budget QoS policy of the discovered writer.
    pub fn latency_budget(&self) -> &LatencyBudgetQosPolicy {
        &self.latency_budget
    }

    /// Get the liveliness QoS policy of the discovered writer.
    pub fn liveliness(&self) -> &LivelinessQosPolicy {
        &self.liveliness
    }

    /// Get the reliability QoS policy of the discovered writer.
    pub fn reliability(&self) -> &ReliabilityQosPolicy {
        &self.reliability
    }

    /// Get the lifespan QoS policy of the discovered writer.
    pub fn lifespan(&self) -> &LifespanQosPolicy {
        &self.lifespan
    }

    /// Get the user data QoS policy of the discovered writer.
    pub fn user_data(&self) -> &UserDataQosPolicy {
        &self.user_data
    }

    /// Get the ownership QoS policy of the discovered writer.
    pub fn ownership(&self) -> &OwnershipQosPolicy {
        &self.ownership
    }

    /// Get the ownership strength QoS policy of the discovered writer.
    pub fn ownership_strength(&self) -> &OwnershipStrengthQosPolicy {
        &self.ownership_strength
    }

    /// Get the destination order QoS policy of the discovered writer.
    pub fn destination_order(&self) -> &DestinationOrderQosPolicy {
        &self.destination_order
    }

    /// Get the presentation QoS policy of the discovered writer.
    pub fn presentation(&self) -> &PresentationQosPolicy {
        &self.presentation
    }

    /// Get the partition QoS policy of the discovered writer.
    pub fn partition(&self) -> &PartitionQosPolicy {
        &self.partition
    }

    /// Get the topic data QoS policy of the topic associated with the discovered writer.
    pub fn topic_data(&self) -> &TopicDataQosPolicy {
        &self.topic_data
    }

    /// Get the group data QoS policy of the discovered writer.
    pub fn group_data(&self) -> &GroupDataQosPolicy {
        &self.group_data
    }

    /// Get the data representation QoS policy of the discovered writer.
    pub fn representation(&self) -> &DataRepresentationQosPolicy {
        &self.representation
    }
}

/// Structure representing a discovered [`DataReader`](crate::subscription::data_reader::DataReader).
#[derive(Debug, PartialEq, Eq, Clone, TypeSupport)]
#[dust_dds(extensibility = "mutable")]
pub struct SubscriptionBuiltinTopicData {
    #[dust_dds(id=PID_ENDPOINT_GUID as u32, key)]
    pub(crate) key: BuiltInTopicKey,
    #[dust_dds(id=PID_PARTICIPANT_GUID as u32, key)]
    pub(crate) participant_key: BuiltInTopicKey,
    #[dust_dds(id=PID_TOPIC_NAME as u32)]
    pub(crate) topic_name: String,
    #[dust_dds(id=PID_TYPE_NAME as u32)]
    pub(crate) type_name: String,
    #[dust_dds(id=PID_DURABILITY as u32, optional)]
    pub(crate) durability: DurabilityQosPolicy,
    #[dust_dds(id=PID_DEADLINE as u32, optional)]
    pub(crate) deadline: DeadlineQosPolicy,
    #[dust_dds(id=PID_LATENCY_BUDGET as u32, optional)]
    pub(crate) latency_budget: LatencyBudgetQosPolicy,
    #[dust_dds(id=PID_LIVELINESS as u32, optional)]
    pub(crate) liveliness: LivelinessQosPolicy,
    #[dust_dds(id=PID_RELIABILITY as u32, optional, default_value=DEFAULT_RELIABILITY_QOS_POLICY_DATA_READER_AND_TOPICS)]
    pub(crate) reliability: ReliabilityQosPolicy,
    #[dust_dds(id=PID_OWNERSHIP as u32, optional)]
    pub(crate) ownership: OwnershipQosPolicy,
    #[dust_dds(id=PID_DESTINATION_ORDER as u32, optional)]
    pub(crate) destination_order: DestinationOrderQosPolicy,
    #[dust_dds(id=PID_USER_DATA as u32, optional)]
    pub(crate) user_data: UserDataQosPolicy,
    #[dust_dds(id=PID_TIME_BASED_FILTER as u32, optional)]
    pub(crate) time_based_filter: TimeBasedFilterQosPolicy,
    #[dust_dds(id=PID_PRESENTATION as u32, optional)]
    pub(crate) presentation: PresentationQosPolicy,
    #[dust_dds(id=PID_PARTITION as u32, optional)]
    pub(crate) partition: PartitionQosPolicy,
    #[dust_dds(id=PID_TOPIC_DATA as u32, optional)]
    pub(crate) topic_data: TopicDataQosPolicy,
    #[dust_dds(id=PID_GROUP_DATA as u32, optional)]
    pub(crate) group_data: GroupDataQosPolicy,
    #[dust_dds(id=PID_DATA_REPRESENTATION as u32, optional)]
    pub(crate) representation: DataRepresentationQosPolicy,
}

impl SubscriptionBuiltinTopicData {
    /// Get the key value of the discovered reader.
    pub fn key(&self) -> &BuiltInTopicKey {
        &self.key
    }

    /// Get the key value of the parent participant of the discovered reader.
    pub fn participant_key(&self) -> &BuiltInTopicKey {
        &self.participant_key
    }

    /// Get the name of the topic associated with the discovered reader.
    pub fn topic_name(&self) -> &str {
        &self.topic_name
    }

    /// Get the name of the type associated with the discovered reader.
    pub fn get_type_name(&self) -> &str {
        &self.type_name
    }

    /// Get the durability QoS policy of the discovered reader.
    pub fn durability(&self) -> &DurabilityQosPolicy {
        &self.durability
    }

    /// Get the deadline QoS policy of the discovered reader.
    pub fn deadline(&self) -> &DeadlineQosPolicy {
        &self.deadline
    }

    /// Get the latency budget QoS policy of the discovered reader.
    pub fn latency_budget(&self) -> &LatencyBudgetQosPolicy {
        &self.latency_budget
    }

    /// Get the liveliness QoS policy of the discovered reader.
    pub fn liveliness(&self) -> &LivelinessQosPolicy {
        &self.liveliness
    }

    /// Get the reliability QoS policy of the discovered reader.
    pub fn reliability(&self) -> &ReliabilityQosPolicy {
        &self.reliability
    }

    /// Get the ownership QoS policy of the discovered reader.
    pub fn ownership(&self) -> &OwnershipQosPolicy {
        &self.ownership
    }

    /// Get the destination order QoS policy of the discovered reader.
    pub fn destination_order(&self) -> &DestinationOrderQosPolicy {
        &self.destination_order
    }

    /// Get the user data QoS policy of the discovered reader.
    pub fn user_data(&self) -> &UserDataQosPolicy {
        &self.user_data
    }

    /// Get the time based filter QoS policy of the discovered reader.
    pub fn time_based_filter(&self) -> &TimeBasedFilterQosPolicy {
        &self.time_based_filter
    }

    /// Get the presentation QoS policy of the discovered reader.
    pub fn presentation(&self) -> &PresentationQosPolicy {
        &self.presentation
    }

    /// Get the partition QoS policy of the discovered reader.
    pub fn partition(&self) -> &PartitionQosPolicy {
        &self.partition
    }

    /// Get the topic data QoS policy of the topic associated with the discovered reader.
    pub fn topic_data(&self) -> &TopicDataQosPolicy {
        &self.topic_data
    }

    /// Get the group data QoS policy of the discovered reader.
    pub fn group_data(&self) -> &GroupDataQosPolicy {
        &self.group_data
    }

    /// Get the data representation QoS policy of the discovered reader.
    pub fn representation(&self) -> &DataRepresentationQosPolicy {
        &self.representation
    }
}