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

DDS Subscriber

See overview at Publisher.

Examples

use rustdds::dds::Subscriber;

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

let subscriber = domain_participant.create_subscriber(&qos);

Implementations

Creates DDS DataReader for keyed Topics

Arguments
  • topic - Reference to the DDS Topic this reader reads from
  • entity_id - Optional EntityId if necessary for DDS communication (random if None)
  • qos - Not in use
Examples
use serde::Deserialize;
use rustdds::serialization::CDRDeserializerAdapter;
use rustdds::dds::data_types::TopicKind;
use rustdds::dds::traits::Keyed;

let subscriber = domain_participant.create_subscriber(&qos).unwrap();

#[derive(Deserialize)]
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_reader = subscriber.create_datareader::<SomeType, CDRDeserializerAdapter<_>>(&topic, None);

Create DDS DataReader for non keyed Topics

Arguments
  • topic - Reference to the DDS Topic this reader reads from
  • entity_id - Optional EntityId if necessary for DDS communication (random if None)
  • qos - Not in use
Examples
use serde::Deserialize;
use rustdds::serialization::CDRDeserializerAdapter;
use rustdds::dds::data_types::TopicKind;

let subscriber = domain_participant.create_subscriber(&qos).unwrap();

#[derive(Deserialize)]
struct SomeType {}

let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
let data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None);

Returns DomainParticipant if it is sill alive.

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

let subscriber = domain_participant.create_subscriber(&qos).unwrap();
assert_eq!(domain_participant, subscriber.participant().unwrap());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Returns the argument unchanged.

Calls U::from(self).

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

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.