zerodds_dcps_async/
publisher.rs1use alloc::sync::Arc;
6
7use zerodds_dcps::{DataWriterQos, DdsType, Publisher, Result, Topic};
8
9use crate::AsyncDataWriter;
10
11#[derive(Clone)]
13pub struct AsyncPublisher {
14 inner: Arc<Publisher>,
15}
16
17impl AsyncPublisher {
18 pub(crate) fn from_sync(inner: Publisher) -> Self {
19 Self {
20 inner: Arc::new(inner),
21 }
22 }
23
24 pub fn create_datawriter<T: DdsType + Send + Sync + 'static>(
29 &self,
30 topic: &Topic<T>,
31 qos: DataWriterQos,
32 ) -> Result<AsyncDataWriter<T>> {
33 let writer = self.inner.create_datawriter::<T>(topic, qos)?;
34 Ok(AsyncDataWriter::from_sync(writer))
35 }
36
37 #[must_use]
39 pub fn as_sync(&self) -> &Publisher {
40 &self.inner
41 }
42}