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
//! The official Rust binding for
//! [Cyclone DDS](https://github.com/eclipse-cyclonedds/cyclonedds).
//!
//! DDS (Data Distribution Service) is a publish-subscribe middleware standard
//! for real-time, data-centric communication. It is used in a variety of
//! mission critical applications in domains such as aerospace, defense,
//! autonomous systems (e.g. vehicles, robotics), industrial control, smart
//! energy grids, transportation, simulation, and medical devices.
//!
//! [`Participants`](Participant) within a specific [`Domain`] discover each
//! other automatically via the DDSI/RTPS discovery protocol. Once two endpoints
//! sharing the same topic name, type information, and compatible
//! [`Quality of Service`][QoS] (`QoS`) discover each other, the middleware
//! establishes a connection between them.
//!
//! [`Publishers`](Publisher) and [`Subscribers`](Subscriber) allow you to group
//! [`Writers`](Writer) and [`Readers`](Reader) respectively to allow you to set
//! their collective behavior. These [`Writers`](Writer) and [`Readers`](Reader)
//! exchange typed samples via [`Topics`](Topic).
//!
//! ```text
//! DOMAIN
//! │
//! ┌──────────────────┴──────────────────┐
//! │ │
//! PARTICIPANT PARTICIPANT
//! │ T ≡ struct Position {x, y} │
//! ┌────┴────┐ ┌────┴────┐
//! │ │ │ │
//! PUBLISHER TOPIC<T> ═══════════════════ TOPIC<T> SUBSCRIBER
//! │ ║ ║ │
//! │ "Position" "Position" │
//! │ ║ ║ │
//! WRITER<T> ═══╝ ╚═══ READER<T>
//! ╰───────── matched via Topic<T> ─────────╯
//! Node 01 Node 02
//! ───────── ─────────
//! ```
//!
//! Data delivery characteristics, such as how samples are buffered,
//! retransmitted, and received, are controlled via [`Quality of Service`][QoS],
//! a collection of
//! [`QoS policies`](qos::policy) that configure characteristics such as:
//!
//! - [`durability`](qos::policy::Durability) (whether late-joining readers
//! receive historical samples)
//!
//! - [`reliability`](qos::policy::Reliability) (best-effort vs reliable
//! delivery)
//!
//! - [`history depth`](qos::policy::History) (the number of samples to store in
//! history)
//!
//! - [`deadline`](qos::policy::Deadline) (whether a signal should be generated
//! when a sample is not received within a specified period)
//!
//! Policies are set independently on the writer and reader side, and
//! compatibility is checked at discovery time. A writer's offered [`QoS`] must
//! be compatible with a reader's requested [`QoS`] for the two endpoints to
//! match.
//!
//! There are a variety of other elements to the DDS API such as:
//!
//! [`WaitSets`](WaitSet): to allow you to block until a particular status
//! occurs on a DDS entity. [`Listeners`](Listener): to notify applications of a
//! change in the status of a particular entity.
//! [`GuardConditions`](GuardCondition), `StatusConditions`,
//! [`ReadConditions`](ReadCondition), and [`QueryConditions`](QueryCondition):
//! Mechanisms to trigger the condition associated with a waitset.
//!
//! See the [DDS Specification](https://www.omg.org/spec/DDS/1.4/About-DDS/) and the [OMG DDS Wiki](https://www.omgwiki.org/ddsf/doku.php?id=ddsf:public:guidebook:01_front:4_toc) for these other elements and see the rest of the Rust Documentation for what is supported by this API.//!
//!
//! # Getting started
//!
//! Every DDS application begins with a [`Domain`] and a [`Participant`]:
//!
//! ```
//! use cyclonedds::{Domain, Participant};
//!
//! let domain = Domain::default();
//! let participant = Participant::new(&domain)?;
//! # Ok::<_, cyclonedds::Error>(())
//! ```
//!
//! Types that can be used as a topic payload must implement the [`Topicable`]
//! trait, either manually or via the
//! [`Topicable`](cyclonedds_macros::Topicable) derive macro. Once you have a
//! topic, create a [`Writer`] or [`Reader`] directly via `new` or through their
//! builders to set [`QoS`] or to associate specific publishers or subscribers.
//! You can then create samples and write them via the writer and read those
//! samples back via the reader.
//!
//! ```
//! # use cyclonedds::{Domain, Participant};
//! # let domain = Domain::default();
//! # let participant = Participant::new(&domain)?;
//! # #[derive(
//! # cyclonedds::Topicable, serde::Serialize, serde::Deserialize, Clone, Debug, Default,
//! # )]
//! # struct MyData {
//! # x: i32,
//! # }
//! use cyclonedds::qos;
//! use cyclonedds::{QoS, Reader, Subscriber, Topic, Writer};
//!
//! let topic = Topic::<MyData>::new(&participant, "MyTopic")?;
//!
//! let qos = QoS::new()
//! .with_reliability(qos::policy::Reliability::BestEffort)
//! .with_history(qos::policy::History::KeepLast { depth: 10 });
//!
//! let subscriber = Subscriber::builder(&participant).with_qos(&qos).build()?;
//!
//! let writer = Writer::builder(&topic).with_qos(&qos).build()?;
//! let reader = Reader::builder(&topic)
//! .with_qos(&qos)
//! .with_subscriber(&subscriber)
//! .build()?;
//!
//! for x in 0..10 {
//! let sample = MyData { x };
//! writer.write(&sample)?;
//! }
//! # assert_eq!(10, reader.read()?.len());
//!
//! // Does not remove the samples from the history,
//! // and does not update metadata.
//! for sample in reader.peek()? {
//! // process sample
//! }
//!
//! // Does not remove the samples from the history,
//! // but does update metadata.
//! for sample in reader.read()? {
//! // process sample
//! }
//!
//! // Removes the samples from the history,
//! // and updates metadata.
//! for sample in reader.take()? {
//! // process sample
//! }
//!
//! # assert_eq!(0, reader.read()?.len());
//! # Ok::<_, cyclonedds::Error>(())
//! ```
//!
//! For further reading, see the [Cyclone DDS
//! documentation](https://cyclonedds.io), the [OMG DDS
//! specification](https://www.omg.org/spec/DDS/), and the
//! [`examples`](https://github.com/eclipse-cyclonedds/cyclonedds-rust/tree/master/cyclonedds/examples).
// NOTE: this is specified here rather than in the common lints within the workspace `Cargo.toml`
// because excluding it for the examples and integration tests is problematic.
// NOTE: active lint levels are defined in the workspace `Cargo.toml`. J
// These `allow`s for the test exist for lints that significantly reduce test readability or
// ergonomics.
pub use Topicable;
pub use Domain;
pub use Duration;
pub use ;
pub use GuardCondition;
pub use ;
pub use Participant;
pub use Publisher;
pub use QoS;
pub use QueryCondition;
pub use ReadCondition;
pub use Reader;
pub use State;
pub use Status;
pub use Subscriber;
pub use Time;
pub use Topic;
pub use ;
pub use WaitSet;
pub use Writer;