Struct rustdds::Subscriber [−][src]
pub struct Subscriber { /* fields omitted */ }
Expand description
Implementations
pub fn create_datareader<D: 'static, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> Result<WithKeyDataReader<D, SA>> where
D: DeserializeOwned + Keyed,
<D as Keyed>::K: Key,
SA: DeserializerAdapter<D>,
pub fn create_datareader<D: 'static, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> Result<WithKeyDataReader<D, SA>> where
D: DeserializeOwned + Keyed,
<D as Keyed>::K: Key,
SA: DeserializerAdapter<D>,
Creates DDS DataReader for keyed Topics
Arguments
topic
- Reference to the DDS Topic this reader reads fromentity_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);
pub fn create_datareader_cdr<D: 'static>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> Result<WithKeyDataReader<D, CDRDeserializerAdapter<D>>> where
D: DeserializeOwned + Keyed,
<D as Keyed>::K: Key,
pub fn create_datareader_no_key<D: 'static, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> Result<NoKeyDataReader<D, SA>> where
D: DeserializeOwned,
SA: DeserializerAdapter<D>,
pub fn create_datareader_no_key<D: 'static, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> Result<NoKeyDataReader<D, SA>> where
D: DeserializeOwned,
SA: DeserializerAdapter<D>,
Create DDS DataReader for non keyed Topics
Arguments
topic
- Reference to the DDS Topic this reader reads fromentity_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);
pub fn create_datareader_no_key_cdr<D: 'static>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> Result<NoKeyDataReader<D, CDRDeserializerAdapter<D>>> where
D: DeserializeOwned,
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
Auto Trait Implementations
impl !RefUnwindSafe for Subscriber
impl Send for Subscriber
impl Sync for Subscriber
impl Unpin for Subscriber
impl !UnwindSafe for Subscriber
Blanket Implementations
Mutably borrows from an owned value. Read more