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 | docs.rs/hdds |
| C | libhdds | C API |
| C++ | hdds-cpp | C++ API |
| Python | hdds | Python API |
Quick Reference
Creating a Participant
- Rust
- C
- C++
- Python
use hdds::prelude::*;
let participant = DomainParticipant::new(0)?;
hdds_participant_t* participant = hdds_participant_create(0, NULL);
hdds::DomainParticipant participant(0);
participant = hdds.DomainParticipant(domain_id=0)
Creating a Topic
- Rust
- C
- C++
- Python
let topic = participant.create_topic::<MyType>("my/topic")?;
hdds_topic_t* topic = hdds_topic_create(participant, "my/topic", "MyType", NULL);
auto topic = participant.create_topic<MyType>("my/topic");
topic = participant.create_topic("my/topic", MyType)
Writing Data
- Rust
- C
- C++
- Python
let writer = participant.create_writer(&topic)?;
writer.write(&data)?;
hdds_writer_t* writer = hdds_writer_create(publisher, topic, NULL);
hdds_writer_write(writer, &data);
auto writer = publisher.create_writer(topic);
writer.write(data);
writer = publisher.create_writer(topic)
writer.write(data)
Reading Data
- Rust
- C
- C++
- Python
let reader = participant.create_reader(&topic)?;
while let Some(sample) = reader.take()? {
println!("{:?}", sample);
}
hdds_reader_t* reader = hdds_reader_create(subscriber, topic, NULL);
MyType data;
hdds_sample_info_t info;
while (hdds_reader_take(reader, &data, &info) == HDDS_OK) {
// process data
}
auto reader = subscriber.create_reader(topic);
for (auto& sample : reader.take()) {
std::cout << sample.data() << std::endl;
}
reader = subscriber.create_reader(topic)
for sample in reader.take():
print(sample)
Core Entities
All DDS implementations share the same core entities:
Feature Comparison
| Feature | Rust | C | C++ | Python |
|---|---|---|---|---|
| Async/Await | Yes | No | C++20 | Yes |
| Zero-copy | Yes | Yes | Yes | No |
| Callbacks | Yes | Yes | Yes | Yes |
| Type Safety | Compile-time | Runtime | Compile-time | Runtime |
| Memory Safety | Guaranteed | Manual | Manual | GC |