API Reference
HDDS provides native bindings for multiple programming languages. Each binding is designed to feel idiomatic in its target language while maintaining consistent DDS semantics.
Supported Languages
| Language | Package | Documentation |
|---|---|---|
| Rust | hdds | Rust API |
| C | libhdds | C API |
| C++ | hdds-cpp | C++ API |
| Python | hdds | Python API |
Quick Reference
Creating a Participant
- Rust
- C
- C++
- Python
use hdds::{Participant, TransportMode};
let participant = Participant::builder("my_app")
.domain_id(0)
.with_transport(TransportMode::UdpMulticast)
.build()?;
struct HddsParticipant *participant =
hdds_participant_create_with_transport("my_app", UDP_MULTICAST);
hdds::Participant participant("my_app");
with hdds.Participant("my_app") as participant:
# use participant
pass
Creating a Writer
- Rust
- C
- C++
- Python
let writer = participant
.topic::<Temperature>("sensors/temp")?
.writer()
.qos(QoS::reliable())
.build()?;
struct HddsQoS *qos = hdds_qos_reliable();
struct HddsDataWriter *writer =
hdds_writer_create_with_qos(participant, "sensors/temp", qos);
hdds_qos_destroy(qos);
auto qos = hdds::QoS::reliable().transient_local();
auto writer = participant.create_writer_raw("sensors/temp", qos);
qos = hdds.QoS.reliable().transient_local()
writer = participant.create_writer("sensors/temp", qos=qos)
Writing Data
- Rust
- C
- C++
- Python
let sample = Temperature { sensor_id: 1, value: 23.5 };
writer.write(&sample)?;
// Raw bytes (use hdds_gen for typed data)
const char *msg = "Hello DDS";
hdds_writer_write(writer, msg, strlen(msg));
std::vector<uint8_t> data = {1, 2, 3, 4};
writer->write_raw(data);
writer.write(b"Hello DDS")
Reading Data
- Rust
- C
- C++
- Python
while let Some(sample) = reader.try_take()? {
println!("Received: {:?}", sample);
}
char buffer[1024];
size_t len;
while (hdds_reader_take(reader, buffer, sizeof(buffer), &len) == OK) {
// process buffer (len bytes)
}
while (auto data = reader->take_raw()) {
// process *data (std::vector<uint8_t>)
}
while (data := reader.take()) is not None:
print(f"Received: {data}")
Core Entities
All DDS implementations share the same core entities:
Feature Comparison
| Feature | Rust | C | C++ | Python |
|---|---|---|---|---|
| Typed Data | #[derive(DDS)] | hdds_gen | hdds_gen | hdds_gen |
| Raw Bytes | Yes | Yes | Yes | Yes |
| Fluent QoS | Yes | No | Yes | Yes |
| RAII | Yes | Manual | Yes | Context Mgr |
| WaitSet | Yes | Yes | Yes | Yes |
| Telemetry | Yes | Yes | Yes | Yes |
| Async/Await | Planned | No | No | Planned |
| Listeners | Planned | Planned | Planned | Planned |