Struct rustdds::DomainParticipant
source · pub struct DomainParticipant { /* private fields */ }
Expand description
DDS DomainParticipant
It is recommended that only one DomainParticipant per OS process is created, as it allocates network sockets, creates background threads, and allocates some memory for object caches.
If you need to communicate to many DDS domains,
then you must create a separate DomainParticipant for each of them.
See DDS Spec v1.4 Section “2.2.1.2.2 Overall Conceptual Model” and
“2.2.2.2.1 DomainParticipant Class” for a definition of a (DDS) domain.
Domains are identified by a domain identifier, which is, in Rust terms, a
u16
. Domain identifier values are application-specific, but 0
is usually
the default.
Implementations§
source§impl DomainParticipant
impl DomainParticipant
sourcepub fn new(domain_id: u16) -> Result<Self>
pub fn new(domain_id: u16) -> Result<Self>
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
sourcepub fn create_publisher(&self, qos: &QosPolicies) -> Result<Publisher>
pub fn create_publisher(&self, qos: &QosPolicies) -> Result<Publisher>
Creates DDS Publisher
Arguments
qos
- Takes qos policies for publisher and given to DataWriter as default.
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();
let publisher = domain_participant.create_publisher(&qos);
sourcepub fn create_subscriber(&self, qos: &QosPolicies) -> Result<Subscriber>
pub fn create_subscriber(&self, qos: &QosPolicies) -> Result<Subscriber>
Creates DDS Subscriber
Arguments
qos
- Takes qos policies for subscriber and given to DataReader as default.
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();
let subscriber = domain_participant.create_subscriber(&qos);
sourcepub fn create_topic(
&self,
name: String,
type_desc: String,
qos: &QosPolicies,
topic_kind: TopicKind
) -> Result<Topic>
pub fn create_topic( &self, name: String, type_desc: String, qos: &QosPolicies, topic_kind: TopicKind ) -> Result<Topic>
Create DDS Topic
Arguments
name
- Name of the topic.type_desc
- Name of the type this topic is supposed to deliver.qos
- Takes qos policies that are distributed to DataReaders and DataWriters.
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();
let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::WithKey);
pub fn find_topic(&self, name: &str, timeout: Duration) -> Result<Option<Topic>>
sourcepub fn domain_id(&self) -> u16
pub fn domain_id(&self) -> u16
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
let domain_id = domain_participant.domain_id();
sourcepub fn participant_id(&self) -> u16
pub fn participant_id(&self) -> u16
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
let participant_id = domain_participant.participant_id();
sourcepub fn discovered_topics(&self) -> Vec<DiscoveredTopicData>
pub fn discovered_topics(&self) -> Vec<DiscoveredTopicData>
Gets all DiscoveredTopics from DDS network
Examples
let domain_participant = DomainParticipant::new(0).unwrap();
let discovered_topics = domain_participant.discovered_topics();
for dtopic in discovered_topics.iter() {
// do something
}
sourcepub fn assert_liveliness(self) -> Result<()>
pub fn assert_liveliness(self) -> Result<()>
Manually asserts liveliness, affecting all writers with LIVELINESS QoS of MANUAL_BY_PARTICIPANT created by this particular participant.
Example
let domain_participant = DomainParticipant::new(0).expect("Failed to create participant");
domain_participant.assert_liveliness();
Trait Implementations§
source§impl Clone for DomainParticipant
impl Clone for DomainParticipant
source§fn clone(&self) -> DomainParticipant
fn clone(&self) -> DomainParticipant
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more