Rust API Surface
What the astutedds crate exports today. The complete documented surface
is also available via cargo doc --open.
Crate items
| Item | Kind |
|---|---|
astutedds::DomainParticipant |
struct |
astutedds::Topic<'a> |
struct |
astutedds::Publisher<'a> |
struct |
astutedds::Subscriber<'a> |
struct |
astutedds::DataWriter<'t> |
struct |
astutedds::DataReader<'t> |
struct |
astutedds::DataWriterQos |
struct (Copy) |
astutedds::DataReaderQos |
struct (Copy) |
astutedds::Reliability |
enum (re-export from astutedds-sys) |
astutedds::HistoryKind |
enum (re-export from astutedds-sys) |
astutedds::Durability |
enum (re-export from astutedds-sys) |
astutedds::Error |
enum |
astutedds::Result<T> |
type alias for std::result::Result<T, Error> |
Entity API
DomainParticipant
| Method | Signature |
|---|---|
new |
fn new(domain_id: u32) -> Result<Self> |
create_topic |
fn create_topic(&self, name: &str, type_name: &str) -> Result<Topic<'_>> |
create_publisher |
fn create_publisher(&self) -> Result<Publisher<'_>> |
create_subscriber |
fn create_subscriber(&self) -> Result<Subscriber<'_>> |
Deletes the participant on Drop. Marked Send + Sync.
Topic<'a>
| Method | Signature |
|---|---|
name |
fn name(&self) -> &str |
type_name |
fn type_name(&self) -> &str |
Publisher<'a>
| Method | Signature |
|---|---|
create_datawriter |
fn create_datawriter<'t>(&self, topic: &'t Topic<'_>, qos: DataWriterQos) -> Result<DataWriter<'t>> |
Subscriber<'a>
| Method | Signature |
|---|---|
create_datareader |
fn create_datareader<'t>(&self, topic: &'t Topic<'_>, qos: DataReaderQos) -> Result<DataReader<'t>> |
DataWriter<'t>
| Method | Signature |
|---|---|
write |
fn write(&self, data: &[u8]) -> Result<()> |
DataReader<'t>
| Method | Signature |
|---|---|
take_next |
fn take_next(&self) -> Result<Vec<u8>> (returns Err(Error::NoData) when the cache is empty) |
unread_count |
fn unread_count(&self) -> usize |
QoS types
pub struct DataWriterQos {
pub reliability: Reliability,
pub history_kind: HistoryKind,
pub history_depth: i32,
pub durability: Durability,
}
pub struct DataReaderQos {
pub reliability: Reliability,
pub history_kind: HistoryKind,
pub history_depth: i32,
pub durability: Durability,
}
Defaults: RELIABLE + KEEP_LAST + depth 1 + VOLATILE.
QoS enums
| Enum | Variants |
|---|---|
Reliability |
ASTUTEDDS_BEST_EFFORT, ASTUTEDDS_RELIABLE |
HistoryKind |
ASTUTEDDS_KEEP_LAST, ASTUTEDDS_KEEP_ALL |
Durability |
ASTUTEDDS_VOLATILE, ASTUTEDDS_TRANSIENT_LOCAL, ASTUTEDDS_TRANSIENT, ASTUTEDDS_PERSISTENT |
Errors
pub enum Error {
ReturnCode(astutedds_sys::AstuteDDS_ReturnCode),
NullPointer,
NulByte(std::ffi::NulError),
NoData,
Timeout,
}
Error implements std::error::Error + Display + Clone + PartialEq + Eq.
From<std::ffi::NulError> is provided so ? works on CString::new(...).
Lifetime model
The borrow checker enforces parent-before-child destruction:
DomainParticipant
├── Topic<'a> (a = lifetime of DomainParticipant)
├── Publisher<'a>
│ └── DataWriter<'t> (t = lifetime of Topic)
└── Subscriber<'a>
└── DataReader<'t> (t = lifetime of Topic)
Dropping a parent before its children fails to compile.
Thread safety
All wrappers are Send + Sync. Wrap any entity in Arc<…> to share it
across threads.
Raw FFI escape hatch
If you need a C API call that is not yet wrapped, depend on
astutedds-sys directly and use unsafe extern functions matching
include/astutedds/c/astutedds.h.