Skip to main content

DataWriter

Struct DataWriter 

Source
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>

Source

pub fn guid(&self) -> Guid

The writer’s GUID.

Source

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.

Writing registers the sample’s instance if it is not yet. KEEP_LAST keeps the newest samples of each instance.

Source

pub fn write_w_timestamp(&self, sample: &T, timestamp: Time) -> Result<()>

Like Self::write, with the source timestamp given.

Source

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).

Source

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.

Source

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.

Source

pub fn unregister_instance_w_timestamp( &self, instance: &T, timestamp: Time, ) -> Result<()>

Like Self::unregister_instance, with the source timestamp given.

Source

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).

Source

pub fn dispose_w_timestamp(&self, instance: &T, timestamp: Time) -> Result<()>

Like Self::dispose, with the source timestamp given.

Source

pub fn lookup_instance(&self, instance: &T) -> Option<InstanceHandle>

The handle of the instance of instance if it is registered (lookup_instance).

Source

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.

Source

pub fn matched_subscriptions(&self) -> Vec<Guid>

The readers matched now (get_matched_subscriptions).

Source

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.

Source

pub fn publication_matched_status(&self) -> MatchedStatus

The PUBLICATION_MATCHED status: the readers matched. Reading it resets the *_change counts.

Source

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.

Source

pub fn clear_listener(&self)

Removes the listener.

Source

pub fn status_changes(&self) -> StatusMask

The statuses changed since they were last read (get_status_changes).

Source

pub fn status_condition(&self) -> StatusCondition

The writer’s StatusCondition (get_statuscondition).

Source

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.

Source

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.

Source

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.

Source

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>

Source

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, 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.

Source

pub fn write_loaned(&self, sample: WriteLoan<T>) -> Result<()>

Publishes a loaned sample, as Self::write does a sample.

Source

pub fn write_loaned_w_timestamp( &self, sample: WriteLoan<T>, timestamp: Time, ) -> Result<()>

Like Self::write_loaned, with the source timestamp given.

Trait Implementations§

Source§

impl<T> Debug for DataWriter<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for DataWriter<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for DataWriter<T>

§

impl<T> !UnwindSafe for DataWriter<T>

§

impl<T> Forget for DataWriter<T>

§

impl<T> Freeze for DataWriter<T>
where Arc<dyn SampleType<T>>: Freeze,

§

impl<T> Move for DataWriter<T>

§

impl<T> Send for DataWriter<T>
where Arc<dyn SampleType<T>>: Send,

§

impl<T> Sync for DataWriter<T>
where Arc<dyn SampleType<T>>: Sync,

§

impl<T> Unpin for DataWriter<T>
where Arc<dyn SampleType<T>>: Unpin,

§

impl<T> UnsafeUnpin for DataWriter<T>
where Arc<dyn SampleType<T>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.