pub struct Publisher { /* private fields */ }
Expand description

DDS Publisher

The Publisher and Subscriber structures are collections of DataWriters and, respectively, DataReaders. They can contain DataWriters or DataReaders of different types, and attacehd to different Topics.

They can act as a domain of sample ordering or atomicity, if such QoS policies are used. For example, DDS participants could agree via QoS policies that data samples must be presented to readers in the same order as writers have written them, and the ordering applies also between several writers/readers, but within one publisher/subscriber. Analogous arrangement can be set up w.r.t. coherency: All the samples in a transaction are delivered to the readers, or none are. The transaction can span several readers, writers, and topics in a single publisher/subscriber.

Examples

use rustdds::dds::Publisher;

let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();

let publisher = domain_participant.create_publisher(&qos);

Implementations

Creates DDS DataWriter for Keyed topic

Arguments
  • entity_id - Custom entity id if necessary for the user to define it
  • topic - Reference to DDS Topic this writer is created to
  • qos - Not currently in use
Examples
use rustdds::dds::traits::Keyed;
use rustdds::serialization::CDRSerializerAdapter;
use serde::Serialize;

let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();

let publisher = domain_participant.create_publisher(&qos).unwrap();

#[derive(Serialize)]
struct SomeType { a: i32 }
impl Keyed for SomeType {
  type K = i32;

  fn key(&self) -> Self::K {
    self.a
  }
}

let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::WithKey).unwrap();
let data_writer = publisher.create_datawriter::<SomeType, CDRSerializerAdapter<_>>(&topic, None);

Shorthand for crate_datawriter with Commaon Data Representation Little Endian

Creates DDS DataWriter for Nokey Topic

Arguments
  • entity_id - Custom entity id if necessary for the user to define it
  • topic - Reference to DDS Topic this writer is created to
  • qos - QoS policies for this DataWriter
Examples
use rustdds::serialization::CDRSerializerAdapter;
use serde::Serialize;

let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();

let publisher = domain_participant.create_publisher(&qos).unwrap();

#[derive(Serialize)]
struct SomeType {}

let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::WithKey).unwrap();
let data_writer = publisher.create_datawriter_no_key::<SomeType, CDRSerializerAdapter<_>>(&topic, None);

Currently does nothing

Currently does nothing

Coherent set not implemented and currently does nothing

Coherent set not implemented and currently does nothing

Wait for all matched reliable DataReaders acknowledge data written so far, or timeout. /Not implemeted/

Gets DomainParticipant if it has not disappeared from all scopes.

Example

let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();

let publisher = domain_participant.create_publisher(&qos).unwrap();
assert_eq!(domain_participant, publisher.participant().unwrap());

Returns default DataWriter qos.

Example
use rustdds::dds::qos::{QosPolicyBuilder};

let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();

let publisher = domain_participant.create_publisher(&qos).unwrap();
assert_eq!(qos, publisher.get_default_datawriter_qos());

Sets default DataWriter qos.

Example

let domain_participant = DomainParticipant::new(0).unwrap();
let qos = QosPolicyBuilder::new().build();

let mut publisher = domain_participant.create_publisher(&qos).unwrap();
let qos2 =
QosPolicyBuilder::new().durability(Durability::Transient).build();
publisher.set_default_datawriter_qos(&qos2);

assert_ne!(qos, publisher.get_default_datawriter_qos());
assert_eq!(qos2, publisher.get_default_datawriter_qos());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.