Struct rustdds::dds::Subscriber[][src]

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

DDS Subscriber

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 get_key(&self) -> Self::K {
    self.a
  }
}

let topic = domain_participant.create_topic("some_topic", "SomeType", &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", "SomeType", &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.get_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

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)

recently added

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.