cyclonedds-rust
Safe, idiomatic Rust bindings for Eclipse CycloneDDS — a high-performance implementation of the OMG Data Distribution Service (DDS) specification.
Highlights
- Complete DDS entity model — DomainParticipant, Publisher, Subscriber, Topic, DataWriter, DataReader
- 26+ QoS policies via a type-safe
QosBuilderpattern - 13 listener callbacks via
ListenerBuilder(data available, matched, liveliness, deadline, etc.) - WaitSet / ReadCondition / QueryCondition / GuardCondition for event-driven architectures
- Derive macros for topic types:
DdsType,DdsEnum,DdsUnion,DdsBitmask - CDR serialization (XCDR1/XCDR2), dynamic types, type discovery (XTypes)
- Async Streams (
read_aiter,take_aiter) with tokio integration - Async Timeouts & Cancellation (
read_aiter_timeout,take_aiter_timeout) with safe cancellation - Zero-Copy Loans (
write_loan,read_loan,take_loan) for minimal latency - DDS Security (
SecurityConfig) with X.509 certificate validation and hot-reload - ROS2 Interop helpers (
ros2_topic_name,ros2_qos_reliable) for seamless ROS2 integration - Diagnostics CLI (
diagnose,metrics) with Prometheus export support tracingIntegration for structured logs and distributed spans- WASM (Experimental) —
cyclonedds-wasmcrate for browser-based DDS over WebSocket - no_std / Embedded (Experimental) — define DDS types without
stdfor embedded targets
Quick Start
Add to your Cargo.toml:
[]
= "1.8"
Define a Topic Type
use *;
Publisher
Subscriber
Async Streams
When the async feature is enabled (default), DataReader provides async iterators over incoming samples:
use DataReader;
use StreamExt;
async
Feature Matrix
| Feature | Python (CycloneDDS) | .NET | Rust (this crate) |
|---|---|---|---|
| Core Entities | Yes | Partial | Yes |
| QoS (26+) | Yes | Partial | Yes |
| Listeners (13) | Yes | Partial | Yes |
| WaitSet / Conditions | Yes | No | Yes |
| CDR Serialization (XCDR1/2) | Yes | Yes | Yes |
| Dynamic Types & Data | Yes | No | Yes |
| Type Discovery (XTypes) | Yes | No | Yes |
| Content-Filtered Topics | Yes | Partial | Yes (closure-based) |
| Union / Bitmask / Enum | Yes | Partial | Yes |
| IDL Compilation | Yes | Yes | Yes |
| CLI Tools | Yes | No | Yes (ls, ps, subscribe, typeof, publish, discover, echo, record, replay, monitor, health, topology) |
Async Streams (read_aiter, take_aiter) |
No | No | Yes |
| Matched Endpoint Data | Yes | No | Yes |
| Zero-copy Write Loan | No | Yes | Yes |
| DDS Security | Yes | No | Yes (SecurityConfig + --features security) |
| Request-Reply Pattern | No | No | Yes (Requester / Replier) |
| Connection Pooling | No | No | Yes (ParticipantPool) |
| Serde Integration | No | No | Yes (SerdeSample<T> + --features serde) |
| WASM (Experimental) | No | No | Yes (cyclonedds-wasm crate) |
| no_std / Embedded (Experimental) | No | No | Yes (--features no_std) |
Workspace Crates
| Crate | Description |
|---|---|
cyclonedds-sys |
Low-level FFI bindings (generated via bindgen) |
cyclonedds |
High-level safe Rust API |
cyclonedds-derive |
Procedural derive macros (DdsType, DdsEnum, DdsUnion, DdsBitmask) |
cyclonedds-build |
Build-time helpers for generating types from IDL |
cyclonedds-idlc |
IDL compiler backend producing Rust source from IDL files |
cyclonedds-cli |
Command-line tools (ls, ps, subscribe, typeof, publish, perf, discover, echo, record, replay, monitor, health, topology) |
cargo-cyclonedds |
Cargo plugin (cargo cyclonedds generate <idl>) |
cyclonedds-bench |
Criterion benchmarks (latency, throughput, CDR) |
cyclonedds-test-suite |
Integration tests |
cyclonedds-wasm |
Experimental WebAssembly bindings (WebSocket transport) |
Build
Requirements
- Rust 1.85+ (MSRV)
- CMake 3.10+
- C/C++ compiler
Note: Clang is no longer required for end users. Prebuilt FFI bindings are shipped with the crate. Clang is only needed if you are a maintainer regenerating bindings (see
scripts/regenerate-bindings.sh).
The bundled CycloneDDS source in cyclonedds-src is built automatically by cyclonedds-rust-sys when CMake is available.
WSL Notes
If building in WSL, ensure libddsc.so is discoverable after the first build:
CLI Examples
# List all topics in a domain
# Show participant status
# Subscribe to a topic
# Subscribe with JSON output and filter
# Show type info
# Publish at 10 Hz
# Monitor throughput
# Health check
# Generate topology graph
# Subscribe to multiple topics simultaneously
# Bridge samples from one topic to another (optionally across domains)
Examples
# Terminal 1 - subscriber
# Terminal 2 - publisher
Documentation
- Getting Started — installation, first steps, WSL notes
- Tutorial — step-by-step first DDS application
- API Guide — tour of all major API features
- Type System —
DdsTypederive, supported types, CDR encoding - QoS Reference — all QoS policies and builder patterns
- ROS2 Integration — communicating with ROS2 nodes
- Security Guide — DDS Security setup and certificates
- Observability —
tracingintegration for structured logs and spans - Benchmarks — running performance benchmarks and comparisons
- Fuzzing — automated fuzz testing with
cargo-fuzz - FAQ — frequently asked questions and troubleshooting
- Migration from Python — guide for
cyclonedds-pythonusers
WASM Support (Experimental)
The cyclonedds-wasm crate provides a DDS-compatible API for WebAssembly:
[]
= "0.1"
use *;
let participant = new.unwrap;
let topic = participant..unwrap;
let writer = participant.create_writer.unwrap;
writer.write.unwrap;
Note: This is not a full DDS implementation. It uses JSON over WebSocket rather than RTPS/CDR. A DDS-to-WebSocket bridge is required to communicate with native DDS participants.
Embedded / no_std (Experimental)
When the no_std feature is enabled, cyclonedds exports only pure-Rust DDS types and constants without the CycloneDDS C FFI:
[]
= { = "1.8", = false, = ["no_std"] }
extern crate alloc;
use ;
This is useful for defining DDS-compatible types on embedded systems (e.g., thumbv7em-none-eabihf) where the full CycloneDDS C library cannot run. Actual CDR serialization must be performed manually or via a separate no-std serializer.
Known Limitations
- CLI
publish: Supports string messages, JSON payloads, and dynamic types discovered at runtime. Complex nested structs may require using the Rust API directly for full control. - DDS Security on Windows: Requires OpenSSL to be installed and
OPENSSL_ROOT_DIRconfigured. Thesecurityfeature is disabled by default on Windows CI to avoid build issues. - WASM: Not a full DDS implementation — requires a WebSocket bridge to communicate with native DDS.
- no_std: No actual DDS networking. Only type definitions and CDR opcode constants are available.
Benchmarks
License
Licensed under the MIT License.
Acknowledgments
Built on Eclipse CycloneDDS — a high-performance DDS implementation.