cyclonedds 3.0.0-alpha.3

Safe Rust wrapper for Eclipse CycloneDDS
Documentation

cyclonedds

crates.io docs.rs

Safe, idiomatic Rust API for Eclipse CycloneDDS. This is the crate most users of the cyclonedds-rust workspace should depend on directly.

It wraps the unsafe FFI surface of cyclonedds-rust-sys with safe entity types (DomainParticipant, Publisher, Subscriber, Topic, DataWriter, DataReader), a type-safe QosBuilder, ListenerBuilder, WaitSet/conditions, async iterator support, zero-copy loans, DDS Security, and more. See the workspace README for the full feature list, feature-flag matrix, and build requirements (CMake 3.16+, a C/C++ compiler).

Install

[dependencies]
cyclonedds = "2.0"

Minimal example

Topic types are usually defined with #[derive(DdsTypeDerive)]:

use cyclonedds::*;

#[derive(DdsTypeDerive, Clone, Debug)]
struct HelloWorld {
    #[key]
    id: i32,
    message: String,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let dp = DomainParticipant::new(0)?;
    let publisher = Publisher::new(&dp)?;
    let topic = Topic::<HelloWorld>::new(dp.entity(), "Hello")?;
    let writer = DataWriter::new(publisher.entity(), topic.entity())?;
    writer.write(&HelloWorld { id: 1, message: "hello".into() })?;
    Ok(())
}

Runnable versions of this pattern live in examples/ (pub.rs, sub.rs, metrics.rs, pub_keyed.rs, sub_async.rs, and more) — run with cargo run -p cyclonedds --example <name>.

Feature flags

default = ["std", "async"].

Feature Adds
std The full entity API (requires cyclonedds-rust-sys)
async read_aiter/take_aiter async streams on DataReader, with timeout/cancellation and batched variants
security SecurityConfig and the cyclonedds::security module (needs an OpenSSL-enabled CycloneDDS build)
tracing tracing-instrumented spans on DDS operations
serde SerdeSample<T>, a postcard-encoded DdsType wrapper for any Serialize + DeserializeOwned type
opentelemetry cyclonedds::observability::init_json_logging() (JSON structured logging via tracing-subscriber)
tokio-console tokio-console instrumentation
no_std Pure-Rust DdsType/opcode definitions only, no networking — use with default-features = false

Full descriptions and rationale: workspace README § Feature Flags.

Documentation

License

MIT — see LICENSE-MIT.