pub struct DataReader<T> { /* private fields */ }Expand description
A DDS data reader (DDS 1.4, 2.2.2.5.3) of samples of type T: a
TopicType, or DynamicData
for a topic of a type known at run time (a DynamicDataReader,
DDS-XTypes 1.3, 7.5.2.12).
Samples that cannot be deserialized as T are dropped when they are
read or taken. Dropping the reader tells the other participants it is
gone.
Implementations§
Source§impl<T> DataReader<T>
impl<T> DataReader<T>
Sourcepub fn take(&self) -> Vec<Sample<T>>
pub fn take(&self) -> Vec<Sample<T>>
Removes and returns the samples received, in the order they arrived.
Sourcepub fn read(&self) -> Vec<Sample<T>>
pub fn read(&self) -> Vec<Sample<T>>
Returns the samples received, in the order they arrived, and leaves them in the reader, marked as read.
Sourcepub fn take_with(&self, filter: StateFilter) -> Vec<Sample<T>>
pub fn take_with(&self, filter: StateFilter) -> Vec<Sample<T>>
Like Self::take, for the samples whose states pass filter.
Sourcepub fn read_with(&self, filter: StateFilter) -> Vec<Sample<T>>
pub fn read_with(&self, filter: StateFilter) -> Vec<Sample<T>>
Like Self::read, for the samples whose states pass filter.
Sourcepub fn take_instance(&self, instance: InstanceHandle) -> Vec<Sample<T>>
pub fn take_instance(&self, instance: InstanceHandle) -> Vec<Sample<T>>
Takes the samples of one instance (take_instance).
Sourcepub fn read_instance(&self, instance: InstanceHandle) -> Vec<Sample<T>>
pub fn read_instance(&self, instance: InstanceHandle) -> Vec<Sample<T>>
Reads the samples of one instance (read_instance).
Sourcepub fn take_next_instance(
&self,
previous: Option<InstanceHandle>,
filter: StateFilter,
) -> Vec<Sample<T>>
pub fn take_next_instance( &self, previous: Option<InstanceHandle>, filter: StateFilter, ) -> Vec<Sample<T>>
Takes the samples of the instance after previous, in handle
order, that has samples passing filter; from the first instance
when previous is None (take_next_instance). Empty when there
is no such instance.
Sourcepub fn read_next_instance(
&self,
previous: Option<InstanceHandle>,
filter: StateFilter,
) -> Vec<Sample<T>>
pub fn read_next_instance( &self, previous: Option<InstanceHandle>, filter: StateFilter, ) -> Vec<Sample<T>>
Like Self::take_next_instance, reading (read_next_instance).
Sourcepub fn max_samples(&self, max_samples: usize) -> MaxSamples<'_, T>
pub fn max_samples(&self, max_samples: usize) -> MaxSamples<'_, T>
The reads and takes of at most max_samples samples (the
max_samples argument of DDS 1.4, 2.2.2.5.3.8): the first to
arrive of those selected. The others stay in the reader as they
were.
Sourcepub fn lookup_instance(&self, instance: &T) -> Option<InstanceHandle>
pub fn lookup_instance(&self, instance: &T) -> Option<InstanceHandle>
The handle of the instance of instance (lookup_instance), if
the reader has it.
Sourcepub fn get_key_value(&self, instance: InstanceHandle) -> Option<T>
pub fn get_key_value(&self, instance: InstanceHandle) -> Option<T>
The key of an instance (get_key_value): the last value received
for it, whose key members identify it. None on a keyless topic,
if the reader has not received a value for it, or if it has
forgotten the instance: one with no samples left and no writers is
forgotten at the read or take after the one that emptied it.
Sourcepub fn wait_for_data(&self, timeout: Duration) -> bool
pub fn wait_for_data(&self, timeout: Duration) -> bool
Waits until there is a sample not yet read, or timeout passes.
Returns whether there is one.
Sourcepub fn set_listener(
&self,
listener: impl DataReaderListener<T> + 'static,
mask: StatusMask,
)where
T: 'static,
pub fn set_listener(
&self,
listener: impl DataReaderListener<T> + 'static,
mask: StatusMask,
)where
T: 'static,
Sets the listener (set_listener), replacing any earlier one:
its methods are called for the statuses in mask when they
change. See DataReaderListener.
Sourcepub fn on_data_available(
&self,
f: impl Fn(&DataReader<T>) + Send + Sync + 'static,
)where
T: 'static,
pub fn on_data_available(
&self,
f: impl Fn(&DataReader<T>) + Send + Sync + 'static,
)where
T: 'static,
Sets a listener for DATA_AVAILABLE alone: f is called with the
reader when samples arrive. It may take them, or send to a
channel:
let (tx, rx) = std::sync::mpsc::channel();
reader.on_data_available(move |r| {
for s in r.take() {
let _ = tx.send(s);
}
});Sourcepub fn clear_listener(&self)
pub fn clear_listener(&self)
Removes the listener.
Sourcepub fn status_changes(&self) -> StatusMask
pub fn status_changes(&self) -> StatusMask
The statuses changed since they were last read
(get_status_changes).
Sourcepub fn status_condition(&self) -> StatusCondition
pub fn status_condition(&self) -> StatusCondition
The reader’s StatusCondition (get_statuscondition).
Sourcepub fn create_readcondition(&self, filter: StateFilter) -> ReadCondition
pub fn create_readcondition(&self, filter: StateFilter) -> ReadCondition
A ReadCondition that is true while the reader has samples whose
states pass filter (create_readcondition). Dropping every
clone of it deletes it.
Sourcepub fn take_w_condition(
&self,
condition: &ReadCondition,
) -> Result<Vec<Sample<T>>>
pub fn take_w_condition( &self, condition: &ReadCondition, ) -> Result<Vec<Sample<T>>>
Takes the samples condition is true for (take_w_condition).
Fails with Error::PreconditionNotMet for a condition of
another reader.
Sourcepub fn read_w_condition(
&self,
condition: &ReadCondition,
) -> Result<Vec<Sample<T>>>
pub fn read_w_condition( &self, condition: &ReadCondition, ) -> Result<Vec<Sample<T>>>
Reads the samples condition is true for (read_w_condition).
Sourcepub fn subscription_matched_status(&self) -> MatchedStatus
pub fn subscription_matched_status(&self) -> MatchedStatus
The SUBSCRIPTION_MATCHED status: the writers matched. Reading it
resets the *_change counts.
Sourcepub fn sample_lost_status(&self) -> SampleLostStatus
pub fn sample_lost_status(&self) -> SampleLostStatus
The SAMPLE_LOST status: samples of matched writers that never
arrived (gaps in their sequence numbers, for a BEST_EFFORT reader).
Reading it resets total_count_change.
Sourcepub fn matched_publications(&self) -> Vec<Guid>
pub fn matched_publications(&self) -> Vec<Guid>
The writers matched now (get_matched_publications).
Sourcepub fn requested_incompatible_qos_status(&self) -> IncompatibleQosStatus
pub fn requested_incompatible_qos_status(&self) -> IncompatibleQosStatus
The REQUESTED_INCOMPATIBLE_QOS status: writers of the same topic,
type and partition that this reader did not match because of
their QoS. Reading it resets total_count_change.
Sourcepub fn sample_rejected_status(&self) -> SampleRejectedStatus
pub fn sample_rejected_status(&self) -> SampleRejectedStatus
The SAMPLE_REJECTED status: samples dropped because of the
reader’s RESOURCE_LIMITS. Reading it resets total_count_change.
Sourcepub fn liveliness_changed_status(&self) -> LivelinessChangedStatus
pub fn liveliness_changed_status(&self) -> LivelinessChangedStatus
The LIVELINESS_CHANGED status: how many matched writers are alive
and how many are not. Reading it resets the *_change counts.
Sourcepub fn requested_deadline_missed_status(&self) -> DeadlineMissedStatus
pub fn requested_deadline_missed_status(&self) -> DeadlineMissedStatus
The REQUESTED_DEADLINE_MISSED status: DEADLINE periods in which an
alive instance got no sample. Reading it resets
total_count_change.
Sourcepub fn wait_for_publications(&self, count: usize, timeout: Duration) -> bool
pub fn wait_for_publications(&self, count: usize, timeout: Duration) -> bool
Waits until at least count writers are matched, or timeout
passes. Returns whether they are.
Source§impl<T: PlainType> DataReader<T>
impl<T: PlainType> DataReader<T>
Sourcepub fn take_loaned(&self) -> Vec<Sample<ReadLoan<T>>>
pub fn take_loaned(&self) -> Vec<Sample<ReadLoan<T>>>
Removes and returns the samples received, in the order they
arrived, without copying them: the samples that a writer of this
host loaned (see
DataWriter::loan_sample) are
read in place in its shared memory, and its slot stays held until
the ReadLoan is dropped. Other samples are deserialized.
Sourcepub fn read_loaned(&self) -> Vec<Sample<ReadLoan<T>>>
pub fn read_loaned(&self) -> Vec<Sample<ReadLoan<T>>>
Like Self::take_loaned, leaving the samples in the reader,
marked as read.
Sourcepub fn take_loaned_max(&self, max: usize) -> Vec<Sample<ReadLoan<T>>>
pub fn take_loaned_max(&self, max: usize) -> Vec<Sample<ReadLoan<T>>>
Like Self::take_loaned, at most max samples.