pub struct Topic<'domain, 'participant, T>where
T: Topicable,{ /* private fields */ }Expand description
A typed communication channel.
A Topic binds a name to a data type T within a
Participant. Writers and
Readers are created against a topic and only match each
other when they share the same topic name and compatible type and
QoS.
Use Topic::new for simple construction or Topic::builder for
QoS and listener
configuration.
Implementations§
Source§impl<'d, 'p, T> Topic<'d, 'p, T>where
T: Topicable,
impl<'d, 'p, T> Topic<'d, 'p, T>where
T: Topicable,
Sourcepub fn new(participant: &'p Participant<'d>, topic_name: &str) -> Result<Self>
pub fn new(participant: &'p Participant<'d>, topic_name: &str) -> Result<Self>
Creates a new Topic with the given name under participant using
default QoS and no
listener.
The topic name identifies the communication channel. Writers and readers match when they share the same name and compatible type.
§Errors
Returns an Error if topic fails to create.
§Examples
use cyclonedds::Topic;
let topic = Topic::<Data>::new(&participant, "MyTopic")?;Sourcepub const fn builder<'q, 'n>(
participant: &'p Participant<'d>,
topic_name: &'n str,
) -> TopicBuilder<'d, 'p, 'q, 'n, T>
pub const fn builder<'q, 'n>( participant: &'p Participant<'d>, topic_name: &'n str, ) -> TopicBuilder<'d, 'p, 'q, 'n, T>
Returns a TopicBuilder for
constructing a topic with custom QoS or a
listener.
§Examples
use cyclonedds::Topic;
let topic = Topic::<Data>::builder(&participant, "MyTopic").build()?;Sourcepub fn set_listener<L>(&mut self, listener: L) -> Result<()>
pub fn set_listener<L>(&mut self, listener: L) -> Result<()>
Sets the TopicListener on this topic,
replacing any previously set listener.
§Errors
Returns an Error if the topic fails to set the
listener.
§Examples
use cyclonedds::listener::TopicListener;
let mut topic = Topic::<Data>::new(&participant, "MyTopic")?;
topic.set_listener(TopicListener::new().with_inconsistent_topic(|_, status| {
println!("inconsistent topic: {status:?}");
}))?;Sourcepub fn unset_listener(&mut self) -> Result<()>
pub fn unset_listener(&mut self) -> Result<()>
Sourcepub fn with_listener<L>(self, listener: L) -> Result<Self>
pub fn with_listener<L>(self, listener: L) -> Result<Self>
Sets the TopicListener on this topic,
consuming and returning self.
§Errors
Returns an Error if the topic fails to set the
listener.
§Examples
use cyclonedds::listener::TopicListener;
let topic = Topic::<Data>::new(&participant, "MyTopic")?.with_listener(TopicListener::new())?;Trait Implementations§
Source§impl<T: Topicable> Entity for Topic<'_, '_, T>
impl<T: Topicable> Entity for Topic<'_, '_, T>
Source§fn instance_handle(&self) -> Result<InstanceHandle>
fn instance_handle(&self) -> Result<InstanceHandle>
InstanceHandle of this entity. Read more