pub struct DataReader<T>where
T: DdsType,{ /* private fields */ }Expand description
Typed DataReader — removes samples that the RTPS reader has received for the topic.
Live mode: rx: Some delivers samples from the runtime mpsc.
Offline mode: in-memory inbox for unit tests.
Implementations§
Source§impl<T> DataReader<T>where
T: DdsType,
impl<T> DataReader<T>where
T: DdsType,
Sourcepub fn with_filter<F>(self, filter: F) -> DataReader<T>
pub fn with_filter<F>(self, filter: F) -> DataReader<T>
Sets a content filter that is evaluated on every sample in the
take() path. Returning false discards the sample.
Builder style: reader.with_filter(|s| s.value > 0).
.7a — SQL expression syntax via set_filter_expression follows
later.
Sourcepub fn subscription_handle(&self) -> InstanceHandle
pub fn subscription_handle(&self) -> InstanceHandle
Spec §2.2.2.5.3.6 / §2.2.2.1.1 — InstanceHandle of this
DataReader. A stable identity for
DomainParticipant::contains_entity.
Sourcepub fn set_listener(
&self,
listener: Option<Arc<dyn DataReaderListener>>,
mask: u32,
)
pub fn set_listener( &self, listener: Option<Arc<dyn DataReaderListener>>, mask: u32, )
Sets the DataReaderListener + StatusMask. None clears the
slot. Spec §2.2.2.5.7.x set_listener.
Sourcepub fn get_listener(&self) -> Option<Arc<dyn DataReaderListener>>
pub fn get_listener(&self) -> Option<Arc<dyn DataReaderListener>>
Current listener clone, if any.
Sourcepub fn qos(&self) -> DataReaderQos
pub fn qos(&self) -> DataReaderQos
Current QoS (cloned, .1).
Sourcepub fn take(&self) -> Result<Vec<T>, DdsError>
pub fn take(&self) -> Result<Vec<T>, DdsError>
Takes all cached samples and removes them from the inbox. Returns an empty Vec if there is nothing.
§Errors
WireErrorif a stored payload can no longer be decoded (type-eval mismatch).
Sourcepub fn read(&self) -> Result<Vec<T>, DdsError>
pub fn read(&self) -> Result<Vec<T>, DdsError>
Reads all samples without removing them. Currently identical to
take minus the removal. Sample state (ReadCondition
§2.2.2.5.8) follows during wire-up.
§Errors
Same as take.
Sourcepub fn matched_publication_count(&self) -> usize
pub fn matched_publication_count(&self) -> usize
Number of matched remote writers. Always 0 in offline mode.
Spec: OMG DDS 1.4 §2.2.2.5.3.15 get_matched_publications.
Side effect — when the matched count changes versus the last
call, on_subscription_matched is fired via the bubble-up chain
(spec §2.2.4.2.6.7).
Sourcepub fn wait_for_matched_publication(
&self,
min_count: usize,
timeout: Duration,
) -> Result<(), DdsError>
pub fn wait_for_matched_publication( &self, min_count: usize, timeout: Duration, ) -> Result<(), DdsError>
Blocks until at least min_count remote writers are matched or
timeout elapses. Event-driven via the runtime condvar
(D.5e phase 1) — wakeup directly when SEDP propagates a match, no
more 20-ms polling.
§Errors
DdsError::Timeout if min_count is not reached within the
time window.
Sourcepub fn requested_deadline_missed_count(&self) -> u64
pub fn requested_deadline_missed_count(&self) -> u64
Counter for requested-deadline violations (spec §2.2.4.2.11
REQUESTED_DEADLINE_MISSED_STATUS). Monotonically increasing;
rises by 1 per expired deadline window without a received sample.
Offline / INFINITE → 0.
May fire on_requested_deadline_missed.
Sourcepub fn requested_incompatible_qos_status(
&self,
) -> RequestedIncompatibleQosStatus
pub fn requested_incompatible_qos_status( &self, ) -> RequestedIncompatibleQosStatus
Current RequestedIncompatibleQosStatus. Spec §2.2.4.2.6.5.
May trigger on_requested_incompatible_qos.
Sourcepub fn sample_lost_count(&self) -> u64
pub fn sample_lost_count(&self) -> u64
SampleLost counter. Spec §2.2.4.2.6.2.
Sourcepub fn sample_rejected_status(&self) -> SampleRejectedStatus
pub fn sample_rejected_status(&self) -> SampleRejectedStatus
SampleRejected status. Spec §2.2.4.2.6.3.
Sourcepub fn drive_listeners(&self)
pub fn drive_listeners(&self)
Polls all reader statuses once and fires pending listeners. Convenience helper for tests + periodic tick callers.
Sourcepub fn liveliness_changed_status(&self) -> (bool, u64, u64)
pub fn liveliness_changed_status(&self) -> (bool, u64, u64)
Liveliness status of the matched writer (spec §2.2.4.2.14
LIVELINESS_CHANGED_STATUS): (alive, alive_count, not_alive_count).
alive: current state (true = writer delivered a sample within its lease duration).alive_count: counter of “not_alive → alive” transitions.not_alive_count: counter of “alive → not_alive” transitions.
Offline / INFINITE lease → (false, 0, 0) / (true, 0, 0)
depending on init. For v1.3 only LivelinessKind::Automatic is
monitored.
Sourcepub fn wait_for_data(&self, timeout: Duration) -> Result<(), DdsError>
pub fn wait_for_data(&self, timeout: Duration) -> Result<(), DdsError>
Blocks until at least one sample is available or the timeout has
elapsed. The sample is not removed in the process — it is placed
in a staging buffer that the next take() reads. This keeps
wait_for_data + take() the canonical subscriber loop instead
of busy-polling in application code.
Spec analog: OMG DDS 1.4 §2.2.2.5.8 ReadCondition + WaitSet.
This API provides the most important semantics (wake-on-data)
without the full WaitSet/Condition infrastructure.
§Errors
DdsError::Timeout if nothing arrives within the time window.
Sourcepub fn instance_tracker(&self) -> InstanceTracker
pub fn instance_tracker(&self) -> InstanceTracker
Returns the current InstanceTracker (shared with the internal
bookkeeping). Mainly for tests / inspection.
Sourcepub fn instance_handle(&self) -> InstanceHandle
pub fn instance_handle(&self) -> InstanceHandle
This reader’s instance handle (GUID-derived). Lets the application
ignore the reader’s own subscription — e.g. a durability service
ignoring its ingest reader on the replay-writer side to avoid an echo
loop. Mirrors crate::DataWriter::instance_handle.
Sourcepub fn notify_writer_liveliness_lost(&self, writer_guid: [u8; 16]) -> usize
pub fn notify_writer_liveliness_lost(&self, writer_guid: [u8; 16]) -> usize
Spec §2.2.3.23 — hook for “writer X lost liveliness”. Does two things:
- clears the OWNERSHIP=EXCLUSIVE owner for all instances whose
owner was this writer (so the next sample from another writer
can win again via
should_accept_sample_under_exclusive_ownership); - returns the number of affected instances.
Called from the WLP path once a writer lease has expired (see
wlp::WlpEndpoint::lost_peers).
Sourcepub fn notify_participant_liveliness_lost(&self, prefix: [u8; 12]) -> usize
pub fn notify_participant_liveliness_lost(&self, prefix: [u8; 12]) -> usize
Like Self::notify_writer_liveliness_lost, but matches only on
the first 12 bytes (GuidPrefix). Allows failover when only the
participant identity is known (e.g. on SPDP lease expiry).
Sourcepub fn lookup_instance(&self, instance: &T) -> InstanceHandle
pub fn lookup_instance(&self, instance: &T) -> InstanceHandle
Turns a sample value into its corresponding local
InstanceHandle, or HANDLE_NIL if unknown / non-keyed.
Spec §2.2.2.5.3.26 lookup_instance (reader variant).
Sourcepub fn get_key_value(&self, handle: InstanceHandle) -> Result<T, DdsError>
pub fn get_key_value(&self, handle: InstanceHandle) -> Result<T, DdsError>
Spec §2.2.2.5.3.25 get_key_value. Returns the sample value with
only the @key fields filled in (reconstructed from the stored
key holder via T::decode).
§Errors
BadParameter if handle is unknown; WireError if T::decode
cannot reconstruct the key stream.
Sourcepub fn take_with_info(&self) -> Result<Vec<Sample<T>>, DdsError>
pub fn take_with_info(&self) -> Result<Vec<Sample<T>>, DdsError>
take with full SampleInfo. Spec §2.2.2.5.3.5 take.
Consumes the samples from the cache (the NOT_READ → READ
transition is moot since they are gone).
§Errors
Same as Self::take.
Sourcepub fn read_with_info(&self) -> Result<Vec<Sample<T>>, DdsError>
pub fn read_with_info(&self) -> Result<Vec<Sample<T>>, DdsError>
read with full SampleInfo. Does not consume — only marks
the samples as READ (spec §2.2.2.5.3.4).
§Errors
Same as Self::read.
Sourcepub fn take_filtered(
&self,
sample_mask: u32,
view_mask: u32,
instance_mask: u32,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn take_filtered( &self, sample_mask: u32, view_mask: u32, instance_mask: u32, ) -> Result<Vec<Sample<T>>, DdsError>
Sourcepub fn read_filtered(
&self,
sample_mask: u32,
view_mask: u32,
instance_mask: u32,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn read_filtered( &self, sample_mask: u32, view_mask: u32, instance_mask: u32, ) -> Result<Vec<Sample<T>>, DdsError>
Sourcepub fn read_w_condition(
&self,
condition: &Arc<QueryCondition>,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn read_w_condition( &self, condition: &Arc<QueryCondition>, ) -> Result<Vec<Sample<T>>, DdsError>
read_w_condition (spec §2.2.2.5.3.7) — in addition to the state
mask, applies the QueryCondition’s SQL filter per sample. Samples
stay in the cache (sample state NOT_READ → READ).
§Errors
PreconditionNotMet on lock poisoning or SQL eval error.
Sourcepub fn take_w_condition(
&self,
condition: &Arc<QueryCondition>,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn take_w_condition( &self, condition: &Arc<QueryCondition>, ) -> Result<Vec<Sample<T>>, DdsError>
take_w_condition (spec §2.2.2.5.3.8) — like read_w_condition,
but consumes the samples (removes them from the cache).
§Errors
PreconditionNotMet on lock poisoning or SQL eval error.
Sourcepub fn read_instance(
&self,
handle: InstanceHandle,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn read_instance( &self, handle: InstanceHandle, ) -> Result<Vec<Sample<T>>, DdsError>
read_instance (spec §2.2.2.5.3.27). Returns only samples of the
given instance.
§Errors
BadParameter if handle == HANDLE_NIL.
Sourcepub fn take_instance(
&self,
handle: InstanceHandle,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn take_instance( &self, handle: InstanceHandle, ) -> Result<Vec<Sample<T>>, DdsError>
take_instance (spec §2.2.2.5.3.27, take variant). Consumes.
§Errors
BadParameter if handle == HANDLE_NIL.
Sourcepub fn read_next_instance(
&self,
previous: InstanceHandle,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn read_next_instance( &self, previous: InstanceHandle, ) -> Result<Vec<Sample<T>>, DdsError>
read_next_instance (spec §2.2.2.5.3.28). Returns the samples of
the next instance (in sort order) after previous.
previous == HANDLE_NIL starts at the first handle.
§Errors
Same as read.
Sourcepub fn take_next_instance(
&self,
previous: InstanceHandle,
) -> Result<Vec<Sample<T>>, DdsError>
pub fn take_next_instance( &self, previous: InstanceHandle, ) -> Result<Vec<Sample<T>>, DdsError>
Trait Implementations§
Source§impl<T> Debug for DataReader<T>where
T: DdsType,
impl<T> Debug for DataReader<T>where
T: DdsType,
Source§impl<T> Drop for DataReader<T>where
T: DdsType,
Available on crate feature std only.RAII teardown (Spec §2.2.2.5.1.2 — deleting a DataReader). Dropping the
user’s handle deregisters the reader from the runtime: it removes the slot,
rebuilds the intra-runtime route, and sends an SEDP dispose so remote peers
drop the matched reader at once. Offline readers (no runtime) are no-ops.
impl<T> Drop for DataReader<T>where
T: DdsType,
std only.RAII teardown (Spec §2.2.2.5.1.2 — deleting a DataReader). Dropping the
user’s handle deregisters the reader from the runtime: it removes the slot,
rebuilds the intra-runtime route, and sends an SEDP dispose so remote peers
drop the matched reader at once. Offline readers (no runtime) are no-ops.
Source§impl<T> Entity for DataReader<T>where
T: DdsType,
Available on crate feature std only.
impl<T> Entity for DataReader<T>where
T: DdsType,
std only.Source§fn set_qos(&self, qos: <DataReader<T> as Entity>::Qos) -> Result<(), DdsError>
fn set_qos(&self, qos: <DataReader<T> as Entity>::Qos) -> Result<(), DdsError>
Spec §2.2.3 / §2.2.2.5.3: DURABILITY, RELIABILITY, HISTORY, RESOURCE_LIMITS, OWNERSHIP are Changeable=NO post-enable.
Source§type Qos = DataReaderQos
type Qos = DataReaderQos
DomainParticipantQos,
DataWriterQos, …).Source§fn get_qos(&self) -> <DataReader<T> as Entity>::Qos
fn get_qos(&self) -> <DataReader<T> as Entity>::Qos
get_qos.Source§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.