Struct rustdds::dds::Subscriber
source · [−]pub struct Subscriber { /* private fields */ }
Expand description
Implementations
sourceimpl Subscriber
impl Subscriber
sourcepub 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,
sourcepub 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,
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
sourceimpl Clone for Subscriber
impl Clone for Subscriber
sourcefn clone(&self) -> Subscriber
fn clone(&self) -> Subscriber
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more