pub struct DomainParticipant { /* private fields */ }Expand description
The participant.
Implementations§
Source§impl DomainParticipant
impl DomainParticipant
Sourcepub fn runtime(&self) -> Option<&Arc<DcpsRuntime>>
pub fn runtime(&self) -> Option<&Arc<DcpsRuntime>>
Internal access to the runtime — used by Publisher/Subscriber to
create DataWriter/Reader. None when the participant is in
offline mode.
Sourcepub fn qos(&self) -> DomainParticipantQos
pub fn qos(&self) -> DomainParticipantQos
Returns a copy of the DomainParticipantQos (Spec §2.2.2.2.1.4
get_qos).
Sourcepub fn set_qos(&self, qos: DomainParticipantQos) -> Result<(), DdsError>
pub fn set_qos(&self, qos: DomainParticipantQos) -> Result<(), DdsError>
Sets the DomainParticipantQos (Spec §2.2.2.2.1.3 set_qos).
§Errors
Currently none — the method always returns Ok(()). The spec
allows IMMUTABLE_POLICY, which we do not actively produce (all
policies are mutable in RC1).
Sourcepub fn register_builtin_types(&self)
pub fn register_builtin_types(&self)
Registers the 4 Spec §7.6.5 built-in types
(DDS::String, DDS::KeyedString, DDS::Bytes, DDS::KeyedBytes)
in the local type registry. Idempotent — a second call overwrites
the entries deterministically.
Called automatically from new()/new_with_runtime(), but can
also be called again after an unregister_builtin_types()
disable.
Sourcepub fn unregister_builtin_types(&self)
pub fn unregister_builtin_types(&self)
Deletes all registered built-in types. Not called from any default path today — a test helper for disable-flag tests.
Sourcepub fn find_builtin_type(&self, name: &str) -> Option<DynamicType>
pub fn find_builtin_type(&self, name: &str) -> Option<DynamicType>
Lookup of a built-in type by spec name (Spec §7.6.5). Returns
Some(DynamicType) if the name is known (registered via
register_builtin_types).
Sourcepub fn registered_type_count(&self) -> usize
pub fn registered_type_count(&self) -> usize
Number of registered built-in types. After new() == 4.
Sourcepub fn enqueue_type_lookup(&self, hash: EquivalenceHash) -> bool
pub fn enqueue_type_lookup(&self, hash: EquivalenceHash) -> bool
Attempts to queue a TypeLookup request for an unknown
EquivalenceHash. Respects backoff (5s between attempts) and at
most 3 retries per hash.
Returns: true if the request was queued, false on backoff
suppression or max attempts.
Sourcepub fn drain_type_lookup_requests(&self) -> Vec<(EquivalenceHash, u64)>
pub fn drain_type_lookup_requests(&self) -> Vec<(EquivalenceHash, u64)>
Drains the queued TypeLookup requests. Returns Vec<(hash, seq)>.
In a production environment the caller would send the hashes via
TypeLookupClient + reliable writer to the TL_SVC_REQ_WRITER
endpoint.
Sourcepub fn ingest_type_lookup_reply(
&self,
types: Vec<(EquivalenceHash, MinimalTypeObject)>,
) -> usize
pub fn ingest_type_lookup_reply( &self, types: Vec<(EquivalenceHash, MinimalTypeObject)>, ) -> usize
Receives a TypeLookup reply (TypeObjects per hash). Registers the TypeObjects in an internal type-registry mirror — afterwards a stalled QoS match can be retried.
Returns the number of successfully registered types.
Sourcepub fn on_remote_publication_discovered(
&self,
type_information_blob: Option<&[u8]>,
) -> usize
pub fn on_remote_publication_discovered( &self, type_information_blob: Option<&[u8]>, ) -> usize
SEDP discovery hook: checks an incoming
PublicationBuiltinTopicData for type hashes that cannot be
resolved locally. If needed, a TypeLookup request is queued via
enqueue_type_lookup.
The RPC path is live via DcpsRuntime::send_type_lookup_request
on the TL_SVC_REQ_* endpoints (XTypes 1.3 §7.6.3.3.4); this method
decides per hash whether a re-request is worthwhile (local
registry lookup + backoff tracking).
Returns: number of unknown hashes queued (max 2 — minimal + complete).
Sourcepub fn on_remote_subscription_discovered(
&self,
type_information_blob: Option<&[u8]>,
) -> usize
pub fn on_remote_subscription_discovered( &self, type_information_blob: Option<&[u8]>, ) -> usize
SEDP discovery hook for SubscriptionBuiltinTopicData. Symmetric
to on_remote_publication_discovered.
Sourcepub fn type_lookup_exhausted(&self, hash: EquivalenceHash) -> bool
pub fn type_lookup_exhausted(&self, hash: EquivalenceHash) -> bool
True if MAX_ATTEMPTS has already been reached for the hash. Consulted by the match-retry path: give up eventually instead of polling forever.
Sourcepub fn create_topic<T>(
&self,
name: &str,
qos: TopicQos,
) -> Result<Topic<T>, DdsError>where
T: DdsType,
pub fn create_topic<T>(
&self,
name: &str,
qos: TopicQos,
) -> Result<Topic<T>, DdsError>where
T: DdsType,
Creates a typed topic handle. Repeated calls with the same name + type return the same handle (ref-shared).
§Errors
InconsistentPolicyif a topic with this name is already registered under a different type.BadParameterfor an empty name.
Sourcepub fn lookup_topicdescription(
&self,
name: &str,
) -> Option<TopicDescriptionHandle>
pub fn lookup_topicdescription( &self, name: &str, ) -> Option<TopicDescriptionHandle>
Immediate local lookup of a topic by name — returns None if no
local create_topic with this name has occurred. Does no
discovery wait (that is find_topic). Spec reference: OMG
DDS 1.4 §2.2.2.2.1.12 “lookup_topicdescription”.
Sourcepub fn find_topic(
&self,
name: &str,
timeout: Duration,
) -> Result<TopicDescriptionHandle, DdsError>
pub fn find_topic( &self, name: &str, timeout: Duration, ) -> Result<TopicDescriptionHandle, DdsError>
Waits until a topic with the given name is visible via discovery
(an SEDP publication or subscription) — or until timeout
elapses. Spec reference: OMG DDS 1.4 §2.2.2.2.1.11 find_topic.
Returns:
Ok(handle)with name + type name + participant, if a matching SEDP endpoint became visible duringtimeout. Local topics count as well (no need to wait ifcreate_topicalready ran).Err(Timeout)iftimeoutelapsed.
§Errors
DdsError::Timeoutiftimeoutelapsed without a discovery match.DdsError::BadParameterfor an empty name.
Sourcepub fn create_contentfilteredtopic<T>(
&self,
name: &str,
related_topic: &Topic<T>,
filter_expression: &str,
filter_parameters: Vec<String>,
) -> Result<ContentFilteredTopic<T>, DdsError>where
T: DdsType,
pub fn create_contentfilteredtopic<T>(
&self,
name: &str,
related_topic: &Topic<T>,
filter_expression: &str,
filter_parameters: Vec<String>,
) -> Result<ContentFilteredTopic<T>, DdsError>where
T: DdsType,
Creates a ContentFilteredTopic as a subset of an existing
Topic<T>. Spec reference: OMG DDS 1.4 §2.2.2.2.1.13
create_contentfilteredtopic.
The filter_expression is a SQL subset (see Annex B).
filter_parameters are strings that replace %0, %1, … in
the expression.
§Errors
BadParameterfor an empty name or empty expression.BadParameterif the filter expression does not parse.BadParameterif a referenced%Nparameter is not supplied in thefilter_parametersvec.
Sourcepub fn create_multitopic<T>(
&self,
name: &str,
type_name: &str,
related_topic_names: Vec<String>,
subscription_expression: &str,
expression_parameters: Vec<String>,
) -> Result<MultiTopic<T>, DdsError>where
T: DdsType,
pub fn create_multitopic<T>(
&self,
name: &str,
type_name: &str,
related_topic_names: Vec<String>,
subscription_expression: &str,
expression_parameters: Vec<String>,
) -> Result<MultiTopic<T>, DdsError>where
T: DdsType,
Creates a MultiTopic as a combining TopicDescription over 1+
underlying topics with a SQL subscription expression. Spec
reference: OMG DDS 1.4 §2.2.2.2.1.15 create_multitopic
(an optional spec feature).
§Errors
BadParameterfor an empty name or type name.BadParameterifrelated_topic_namesis empty.BadParameterif the subscription expression does not parse.BadParameterif a referenced%Nparameter is not supplied in theexpression_parametersvec.
Sourcepub fn delete_multitopic<T>(&self, mt: &MultiTopic<T>) -> Result<(), DdsError>where
T: DdsType,
pub fn delete_multitopic<T>(&self, mt: &MultiTopic<T>) -> Result<(), DdsError>where
T: DdsType,
Deletes a MultiTopic. Spec §2.2.2.2.1.16 delete_multitopic.
In v1.2 it is a no-op shim with a participant match check.
§Errors
BadParameter if the MultiTopic belongs to a different
participant.
Sourcepub fn delete_contentfilteredtopic<T>(
&self,
cft: &ContentFilteredTopic<T>,
) -> Result<(), DdsError>where
T: DdsType,
pub fn delete_contentfilteredtopic<T>(
&self,
cft: &ContentFilteredTopic<T>,
) -> Result<(), DdsError>where
T: DdsType,
Deletes a ContentFilteredTopic. Spec reference: §2.2.2.2.1.14
delete_contentfilteredtopic.
In Rust, the CFT’s lifetime handle is already covered by Drop —
the underlying resources are freed once the
ContentFilteredTopic<T> goes out of scope. This method exists
for spec compliance of the C++ API and validates the participant
match (the spec requires BadParameter if the CFT belongs to a
different participant).
§Errors
BadParameterif the CFT belongs to a different participant.
Sourcepub fn create_publisher(&self, qos: PublisherQos) -> Publisher
pub fn create_publisher(&self, qos: PublisherQos) -> Publisher
Creates a publisher with the given QoS (the default is enough for v1.2).
Sourcepub fn create_subscriber(&self, qos: SubscriberQos) -> Subscriber
pub fn create_subscriber(&self, qos: SubscriberQos) -> Subscriber
Creates a subscriber.
Sourcepub fn topics_len(&self) -> usize
pub fn topics_len(&self) -> usize
Number of currently registered topics. Diagnostic API.
Sourcepub fn discovered_participants_count(&self) -> usize
pub fn discovered_participants_count(&self) -> usize
Number of currently discovered remote participants via SPDP.
Spec: OMG DDS 1.4 §2.2.2.2.1.7 get_discovered_participants.
0 in offline mode.
Sourcepub fn discovered_publications_count(&self) -> usize
pub fn discovered_publications_count(&self) -> usize
Number of remote publications currently known in the SEDP cache.
Spec: OMG DDS 1.4 §2.2.2.2.1.9 get_discovered_topics (~analogous).
Sourcepub fn discovered_subscriptions_count(&self) -> usize
pub fn discovered_subscriptions_count(&self) -> usize
Number of remote subscriptions currently known in the SEDP cache.
Sourcepub fn ignore_participant(&self, handle: InstanceHandle) -> Result<(), DdsError>
pub fn ignore_participant(&self, handle: InstanceHandle) -> Result<(), DdsError>
Marks a discovered remote DomainParticipant as “ignored” — all
further SPDP beacons with this handle drop out of the builtin
reader stream, and at the same time all SEDP endpoints belonging
to the same participant prefix are also discarded
(Spec §2.2.2.2.1.14).
Per spec the action is monotonic — a once-ignored participant stays ignored for the lifetime of this participant.
§Errors
Currently none — the method always returns Ok(()). The spec
allows OUT_OF_RESOURCES, which we do not actively produce.
Sourcepub fn ignore_topic(&self, handle: InstanceHandle) -> Result<(), DdsError>
pub fn ignore_topic(&self, handle: InstanceHandle) -> Result<(), DdsError>
Marks a discovered remote topic as “ignored”. Spec §2.2.2.2.1.15.
§Errors
Sourcepub fn ignore_publication(&self, handle: InstanceHandle) -> Result<(), DdsError>
pub fn ignore_publication(&self, handle: InstanceHandle) -> Result<(), DdsError>
Marks a discovered remote publication as “ignored”. Spec §2.2.2.2.1.16.
§Errors
Sourcepub fn ignore_subscription(
&self,
handle: InstanceHandle,
) -> Result<(), DdsError>
pub fn ignore_subscription( &self, handle: InstanceHandle, ) -> Result<(), DdsError>
Marks a discovered remote subscription as “ignored”. Spec §2.2.2.2.1.17.
§Errors
Sourcepub fn is_participant_ignored(&self, handle: InstanceHandle) -> bool
pub fn is_participant_ignored(&self, handle: InstanceHandle) -> bool
true if handle was marked via ignore_participant.
Sourcepub fn is_topic_ignored(&self, handle: InstanceHandle) -> bool
pub fn is_topic_ignored(&self, handle: InstanceHandle) -> bool
true if handle was marked via ignore_topic.
Sourcepub fn is_publication_ignored(&self, handle: InstanceHandle) -> bool
pub fn is_publication_ignored(&self, handle: InstanceHandle) -> bool
true if handle was marked via ignore_publication.
Sourcepub fn is_subscription_ignored(&self, handle: InstanceHandle) -> bool
pub fn is_subscription_ignored(&self, handle: InstanceHandle) -> bool
true if handle was marked via ignore_subscription.
Sourcepub fn delete_contained_entities(&self) -> Result<(), DdsError>
pub fn delete_contained_entities(&self) -> Result<(), DdsError>
Deletes all children held by the participant (publishers, subscribers, topics, builtin reader inboxes). Spec §2.2.2.2.1.18 — an analogous counterpart exists in Publisher/Subscriber/DataReader, which is covered here recursively.
Offline behavior:
- Topic registry cleared (local topics).
- Publisher/subscriber trackers cleared.
- Builtin-topic reader inboxes cleared (so that
take()afterdelete_contained_entitiesreturns an empty vec). - No SEDP unannounce — the live behavior handles that once
the runtime gets a
Drop/shutdownhandle. Current state: the runtime thread runs until process exit.
§Errors
PreconditionNotMet if an internal mutex is poisoned.
Sourcepub fn publishers_len(&self) -> usize
pub fn publishers_len(&self) -> usize
Number of publishers tracked via create_publisher. Diagnostic
API for tests.
Sourcepub fn subscribers_len(&self) -> usize
pub fn subscribers_len(&self) -> usize
Number of subscribers tracked via create_subscriber.
Sourcepub fn instance_handle(&self) -> InstanceHandle
pub fn instance_handle(&self) -> InstanceHandle
Returns this participant’s InstanceHandle. Identifies the entity
to DCPS API consumers (Spec §2.2.2.1.1 get_instance_handle).
Sourcepub fn participant_handle(&self) -> InstanceHandle
pub fn participant_handle(&self) -> InstanceHandle
This participant’s discovery-space handle: InstanceHandle::from_guid
of its participant GUID.
Unlike Self::instance_handle (a local allocator counter), this is the
handle the ignore filter and discovery actually key on. It is therefore
the correct argument to ignore THIS participant from another one — e.g. a
durability service whose sibling ingest/replay participants must ignore
each other to avoid an echo loop. HANDLE_NIL when offline.
Sourcepub fn contains_entity(&self, handle: InstanceHandle) -> bool
pub fn contains_entity(&self, handle: InstanceHandle) -> bool
Spec §2.2.2.2.1.10 contains_entity — true if handle belongs
to this participant or one of its directly or recursively
contained entities.
Included entity types:
- the participant itself
- all topics registered via
create_topic - all publishers/subscribers created via
create_publisher/create_subscriber - recursively: all DataWriter/DataReader created via
Publisher::create_datawriter/Subscriber::create_datareader.
Sourcepub fn get_discovered_participants(&self) -> Vec<InstanceHandle>
pub fn get_discovered_participants(&self) -> Vec<InstanceHandle>
Returns the InstanceHandles of all currently discovered remote
participants (Spec §2.2.2.2.1.27). Empty in offline mode. Ignored
participants do not appear.
Sourcepub fn get_discovered_participant_data(
&self,
handle: InstanceHandle,
) -> Result<ParticipantBuiltinTopicData, DdsError>
pub fn get_discovered_participant_data( &self, handle: InstanceHandle, ) -> Result<ParticipantBuiltinTopicData, DdsError>
Returns the ParticipantBuiltinTopicData for a handle from
get_discovered_participants (Spec §2.2.2.2.1.28).
§Errors
BadParameter if handle does not reference a discovered
participant (or if it was ignored).
Sourcepub fn get_discovered_topics(&self) -> Vec<InstanceHandle>
pub fn get_discovered_topics(&self) -> Vec<InstanceHandle>
Returns the InstanceHandles of all currently discovered remote
topics. Spec §2.2.2.2.1.29.
Topics are discovered indirectly via SEDP pub/sub announcements —
per (topic_name, type_name) we synthesize a stable key via
TopicBuiltinTopicData::synthesize_key. Ignored topics do not
appear.
Sourcepub fn get_discovered_topic_data(
&self,
handle: InstanceHandle,
) -> Result<TopicBuiltinTopicData, DdsError>
pub fn get_discovered_topic_data( &self, handle: InstanceHandle, ) -> Result<TopicBuiltinTopicData, DdsError>
Returns the TopicBuiltinTopicData for a handle from
get_discovered_topics. Spec §2.2.2.2.1.30.
§Errors
BadParameter if handle does not correspond to a discovered
topic (or was ignored).
Sourcepub fn get_builtin_subscriber(&self) -> Arc<BuiltinSubscriber>
pub fn get_builtin_subscriber(&self) -> Arc<BuiltinSubscriber>
The participant’s builtin subscriber (DDS 1.4 §2.2.2.2.1.7).
Always returns the same subscriber handle (exactly one builtin subscriber per participant). It contains 4 pre-created readers for the builtin topics:
DCPSParticipant→ParticipantBuiltinTopicDataDCPSTopic→TopicBuiltinTopicDataDCPSPublication→PublicationBuiltinTopicDataDCPSSubscription→SubscriptionBuiltinTopicData
SPDP/SEDP receive internally triggers a sample insert that can be
picked up via take()/read() (DDS 1.4 §2.2.5).
§Example
use zerodds_dcps::*;
let participant = DomainParticipantFactory::instance()
.create_participant_offline(0, DomainParticipantQos::default());
let bs = participant.get_builtin_subscriber();
let r = bs
.lookup_datareader::<DcpsParticipantBuiltinTopicData>("DCPSParticipant")
.expect("builtin reader");
// Initially empty (offline mode → no SPDP receives).
assert!(r.take().expect("take").is_empty());Sourcepub fn set_listener(
&self,
listener: Option<Arc<dyn DomainParticipantListener>>,
mask: u32,
)
pub fn set_listener( &self, listener: Option<Arc<dyn DomainParticipantListener>>, mask: u32, )
Sets the DomainParticipantListener. listener=None clears the
slot. mask is the StatusMask that determines which status
bits this listener consumes (Spec §2.2.4.2.3 bubble-up).
Sourcepub fn get_listener(&self) -> Option<Arc<dyn DomainParticipantListener>>
pub fn get_listener(&self) -> Option<Arc<dyn DomainParticipantListener>>
Returns the currently installed listener clone, if present. Spec §2.2.2.2.3.x get_listener.
Trait Implementations§
Source§impl Clone for DomainParticipant
impl Clone for DomainParticipant
Source§fn clone(&self) -> DomainParticipant
fn clone(&self) -> DomainParticipant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DomainParticipant
impl Debug for DomainParticipant
Source§impl Entity for DomainParticipant
impl Entity for DomainParticipant
Source§type Qos = DomainParticipantQos
type Qos = DomainParticipantQos
DomainParticipantQos,
DataWriterQos, …).Source§fn get_qos(&self) -> <DomainParticipant as Entity>::Qos
fn get_qos(&self) -> <DomainParticipant as Entity>::Qos
get_qos.Source§fn set_qos(
&self,
qos: <DomainParticipant as Entity>::Qos,
) -> Result<(), DdsError>
fn set_qos( &self, qos: <DomainParticipant as Entity>::Qos, ) -> Result<(), DdsError>
ImmutablePolicy error. Spec §2.2.2.1.2 set_qos. Read moreSource§fn enable(&self) -> Result<(), DdsError>
fn enable(&self) -> Result<(), DdsError>
enable. Read moreSource§fn entity_state(&self) -> Arc<EntityState>
fn entity_state(&self) -> Arc<EntityState>
Arc<EntityState>.Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Source§fn get_status_condition(&self) -> StatusCondition
fn get_status_condition(&self) -> StatusCondition
StatusCondition of this entity.
Spec §2.2.2.1.6 get_status_condition.Source§fn get_status_changes(&self) -> u32
fn get_status_changes(&self) -> u32
get_status_changes.Source§fn get_instance_handle(&self) -> InstanceHandle
fn get_instance_handle(&self) -> InstanceHandle
get_instance_handle.