pub struct DataWriter<T> { /* private fields */ }Expand description
A DDS data writer (DDS 1.4, 2.2.2.4.2) of samples of type T: a
TopicType, or DynamicData
for a topic of a type known at run time (a DynamicDataWriter,
DDS-XTypes 1.3, 7.5.2.12).
Dropping it tells the other participants it is gone.
Implementations§
Source§impl<T> DataWriter<T>
impl<T> DataWriter<T>
Sourcepub fn write(&self, sample: &T) -> Result<()>
pub fn write(&self, sample: &T) -> Result<()>
Publishes a sample: serializes it in XCDR1, or XCDR2 if that is the writer’s data representation (in the host’s byte order), and sends it to every matched reader.
A RELIABLE writer with KEEP_ALL history and max_samples set
waits, when its history is full, for its readers to acknowledge
samples; after max_blocking_time it fails with
Error::Timeout. A RELIABLE KEEP_ALL
writer with more than 2 MiB its readers have not acknowledged also
waits, up to max_blocking_time, and then writes anyway.
Writing registers the sample’s instance if it is not yet. KEEP_LAST keeps the newest samples of each instance.
Sourcepub fn write_w_timestamp(&self, sample: &T, timestamp: Time) -> Result<()>
pub fn write_w_timestamp(&self, sample: &T, timestamp: Time) -> Result<()>
Like Self::write, with the source timestamp given.
Sourcepub fn write_w_params(
&self,
sample: &T,
params: &WriteParams,
) -> Result<SampleIdentity>
pub fn write_w_params( &self, sample: &T, params: &WriteParams, ) -> Result<SampleIdentity>
Like Self::write, with the parameters given; returns the
identity of the sample written (its writer and sequence number),
which a reply names as its related sample (DDS-RPC 1.0, 7.8.2).
Sourcepub fn register_instance(&self, instance: &T) -> Result<InstanceHandle>
pub fn register_instance(&self, instance: &T) -> Result<InstanceHandle>
Registers the instance of instance (whose key members are what
counts) and returns its handle (register_instance). This sends
nothing: readers learn of the instance when it is written.
Sourcepub fn unregister_instance(&self, instance: &T) -> Result<()>
pub fn unregister_instance(&self, instance: &T) -> Result<()>
Unregisters an instance (unregister_instance): this writer has
nothing more to say about it. A reader’s instance becomes
NOT_ALIVE_NO_WRITERS once no writer has it registered, or
NOT_ALIVE_DISPOSED when autodispose_unregistered_instances is
set. Fails with
Error::PreconditionNotMet
when the instance is not registered.
Sourcepub fn unregister_instance_w_timestamp(
&self,
instance: &T,
timestamp: Time,
) -> Result<()>
pub fn unregister_instance_w_timestamp( &self, instance: &T, timestamp: Time, ) -> Result<()>
Like Self::unregister_instance, with the source timestamp
given.
Sourcepub fn dispose(&self, instance: &T) -> Result<()>
pub fn dispose(&self, instance: &T) -> Result<()>
Disposes an instance (dispose): readers see it
NOT_ALIVE_DISPOSED until it is written again. The instance stays
registered (or is registered).
Sourcepub fn dispose_w_timestamp(&self, instance: &T, timestamp: Time) -> Result<()>
pub fn dispose_w_timestamp(&self, instance: &T, timestamp: Time) -> Result<()>
Like Self::dispose, with the source timestamp given.
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 if it is registered
(lookup_instance).
Sourcepub fn wait_for_acknowledgments(&self, max_wait: Duration) -> Result<()>
pub fn wait_for_acknowledgments(&self, max_wait: Duration) -> Result<()>
Waits until every matched RELIABLE reader has acknowledged every
sample written (wait_for_acknowledgments). Fails with
Error::Timeout if max_wait passes
first.
Sourcepub fn matched_subscriptions(&self) -> Vec<Guid>
pub fn matched_subscriptions(&self) -> Vec<Guid>
The readers matched now (get_matched_subscriptions).
Sourcepub fn offered_incompatible_qos_status(&self) -> IncompatibleQosStatus
pub fn offered_incompatible_qos_status(&self) -> IncompatibleQosStatus
The OFFERED_INCOMPATIBLE_QOS status: readers of the same topic,
type and partition that this writer did not match because of its
QoS. Reading it resets total_count_change.
Sourcepub fn publication_matched_status(&self) -> MatchedStatus
pub fn publication_matched_status(&self) -> MatchedStatus
The PUBLICATION_MATCHED status: the readers matched. Reading it
resets the *_change counts.
Sourcepub fn set_listener(
&self,
listener: impl DataWriterListener<T> + 'static,
mask: StatusMask,
)where
T: 'static,
pub fn set_listener(
&self,
listener: impl DataWriterListener<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 DataWriterListener.
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 writer’s StatusCondition (get_statuscondition).
Sourcepub fn assert_liveliness(&self) -> Result<()>
pub fn assert_liveliness(&self) -> Result<()>
Asserts the writer’s liveliness (assert_liveliness, DDS 1.4,
2.2.2.4.2.22), for a MANUAL_BY_PARTICIPANT or MANUAL_BY_TOPIC
writer that has nothing to write; writing asserts it too. It does
nothing for an AUTOMATIC writer, whose participant asserts it.
Sourcepub fn liveliness_lost_status(&self) -> LivelinessLostStatus
pub fn liveliness_lost_status(&self) -> LivelinessLostStatus
The LIVELINESS_LOST status: how many times the writer’s lease
passed without it asserting its liveliness. Reading it resets
total_count_change.
Sourcepub fn offered_deadline_missed_status(&self) -> DeadlineMissedStatus
pub fn offered_deadline_missed_status(&self) -> DeadlineMissedStatus
The OFFERED_DEADLINE_MISSED status: DEADLINE periods in which a
registered instance was not written. Reading it resets
total_count_change.
Sourcepub fn wait_for_subscriptions(&self, count: usize, timeout: Duration) -> bool
pub fn wait_for_subscriptions(&self, count: usize, timeout: Duration) -> bool
Waits until at least count readers are matched, or timeout
passes. Returns whether they are.
Source§impl<T: PlainType> DataWriter<T>
impl<T: PlainType> DataWriter<T>
Sourcepub fn loan_sample(&self) -> Result<WriteLoan<T>>
pub fn loan_sample(&self) -> Result<WriteLoan<T>>
Lends a sample to fill and then publish with
Self::write_loaned (zero-copy): a sample in the writer’s pool
in shared memory, which the readers of this host read in place,
with no serialization and no copy. It holds zeros, or an earlier
sample of the writer when its slot is used again: set every member.
The sample goes by reference when every reader matched is of this
participant or reached by shared memory, the writer is VOLATILE
and DDS Security is off; otherwise its octets are sent, as for
Self::write, still without serialization. The sample is on
the heap, and serialized when written, when the pool cannot be
used: without shared memory (feature shm and
ParticipantConfig::shared_memory),
with DDS Security, when every slot of the pool is held (a reliable
writer first waits up to max_blocking_time for one), or when
the layout of T is not its serialized form (see PlainType).
A slot of the pool is used again once the writer’s history no longer has its sample (and it is not one of the newest few) and every reader has dropped it.
Sourcepub fn write_loaned(&self, sample: WriteLoan<T>) -> Result<()>
pub fn write_loaned(&self, sample: WriteLoan<T>) -> Result<()>
Publishes a loaned sample, as Self::write does a sample.
Sourcepub fn write_loaned_w_timestamp(
&self,
sample: WriteLoan<T>,
timestamp: Time,
) -> Result<()>
pub fn write_loaned_w_timestamp( &self, sample: WriteLoan<T>, timestamp: Time, ) -> Result<()>
Like Self::write_loaned, with the source timestamp given.