Struct rustdds::Publisher

source ·
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§

source§

impl Publisher

source

pub fn create_datawriter<D, SA>( &self, topic: &Topic, qos: Option<QosPolicies> ) -> Result<WithKeyDataWriter<D, SA>>where D: Keyed + Serialize, <D as Keyed>::K: Key, SA: SerializerAdapter<D>,

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);
source

pub fn create_datawriter_cdr<D>( &self, topic: &Topic, qos: Option<QosPolicies> ) -> Result<WithKeyDataWriter<D, CDRSerializerAdapter<D, LittleEndian>>>where D: Keyed + Serialize, <D as Keyed>::K: Key,

Shorthand for crate_datawriter with Commaon Data Representation Little Endian

source

pub fn create_datawriter_no_key<D, SA>( &self, topic: &Topic, qos: Option<QosPolicies> ) -> Result<NoKeyDataWriter<D, SA>>where D: Serialize, SA: SerializerAdapter<D>,

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);
source

pub fn create_datawriter_no_key_cdr<D>( &self, topic: &Topic, qos: Option<QosPolicies> ) -> Result<NoKeyDataWriter<D, CDRSerializerAdapter<D, LittleEndian>>>where D: Serialize,

source

pub fn suspend_publications(&self) -> Result<()>

👎Deprecated: unimplemented

NOT IMPLEMENTED. DO NOT USE

source

pub fn resume_publications(&self) -> Result<()>

👎Deprecated: unimplemented

NOT IMPLEMENTED. DO NOT USE

source

pub fn begin_coherent_changes(&self) -> Result<()>

👎Deprecated: unimplemented

NOT IMPLEMENTED. DO NOT USE

source

pub fn end_coherent_changes(&self) -> Result<()>

👎Deprecated: unimplemented

NOT IMPLEMENTED. DO NOT USE

source

pub fn wait_for_acknowledgments(&self, _max_wait: Duration) -> Result<()>

👎Deprecated: unimplemented

NOT IMPLEMENTED. DO NOT USE

source

pub fn participant(&self) -> Option<DomainParticipant>

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());
source

pub fn get_default_datawriter_qos(&self) -> QosPolicies

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());
source

pub fn set_default_datawriter_qos(&mut self, q: &QosPolicies)

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§

source§

impl Clone for Publisher

source§

fn clone(&self) -> Publisher

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Publisher

source§

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

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

impl PartialEq<Publisher> for Publisher

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V