Struct rustdds::Subscriber
source · pub struct Subscriber { /* private fields */ }
Expand description
Implementations§
source§impl Subscriber
impl Subscriber
sourcepub fn create_datareader<D, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<WithKeyDataReader<D, SA>>where
D: 'static + Keyed,
SA: DeserializerAdapter<D>,
pub fn create_datareader<D, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<WithKeyDataReader<D, SA>>where
D: 'static + Keyed,
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;
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>( &self, topic: &Topic, qos: Option<QosPolicies> ) -> CreateResult<WithKeyDataReader<D, CDRDeserializerAdapter<D>>>
sourcepub fn create_datareader_no_key<D, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<NoKeyDataReader<D, SA>>where
D: 'static,
SA: DeserializerAdapter<D>,
pub fn create_datareader_no_key<D, SA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<NoKeyDataReader<D, SA>>where
D: 'static,
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;
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_simple_datareader_no_key<D, DA>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<SimpleDataReader<D, DA>>where
D: 'static,
DA: 'static + DeserializerAdapter<D>,
pub fn create_datareader_no_key_cdr<D>(
&self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<NoKeyDataReader<D, CDRDeserializerAdapter<D>>>where
D: 'static + DeserializeOwned,
sourcepub fn participant(&self) -> Option<DomainParticipant>
pub fn participant(&self) -> Option<DomainParticipant>
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§
source§impl Clone for Subscriber
impl Clone for Subscriber
source§fn clone(&self) -> Subscriber
fn clone(&self) -> Subscriber
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for Subscriber
impl !RefUnwindSafe for Subscriber
impl Send for Subscriber
impl Sync for Subscriber
impl Unpin for Subscriber
impl !UnwindSafe for Subscriber
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more