pub struct Subscriber<'domain, 'participant> { /* private fields */ }Expand description
A Subscriber groups Readers and controls their shared
QoS. Readers created under a subscriber inherit its
QoS where applicable.
Use Subscriber::new for simple construction or Subscriber::builder
for QoS and
listener configuration.
In most applications a subscriber is created implicitly when constructing a
Reader directly. Use an explicit subscriber when you need
coordinated reads across multiple readers.
Implementations§
Source§impl<'d, 'p> Subscriber<'d, 'p>
impl<'d, 'p> Subscriber<'d, 'p>
Sourcepub fn new(participant: &'p Participant<'d>) -> Result<Self>
pub fn new(participant: &'p Participant<'d>) -> Result<Self>
Sourcepub const fn builder<'q>(
participant: &'p Participant<'d>,
) -> SubscriberBuilder<'d, 'p, 'q>
pub const fn builder<'q>( participant: &'p Participant<'d>, ) -> SubscriberBuilder<'d, 'p, 'q>
Returns a SubscriberBuilder for
constructing a subscriber with custom QoS or a
listener.
§Examples
use cyclonedds::{
QoS, Subscriber,
qos::policy::{Durability, Presentation},
};
let qos = QoS::new().with_presentation(Presentation::Topic {
coherent_access: true,
ordered_access: true,
});
let subscriber = Subscriber::builder(&participant).with_qos(&qos).build()?;
Ok::<_, cyclonedds::Error>(())Sourcepub fn notify_readers(&self) -> Result<()>
pub fn notify_readers(&self) -> Result<()>
(WARN: unimplemented in C lib): Notifies all readers belonging to this subscriber that data is available.
This function is currently not implemented by the underlying C library and will thus always return an unsupported error.
Triggers the
DataOnReaders
callback on the subscriber’s listener and the
DataAvailable
callback on each reader’s listener.
§Errors
Returns an Error if the subscriber fails to notify the
readers.
§Examples
use cyclonedds::Subscriber;
let subscriber = Subscriber::new(&participant)?;
subscriber.notify_readers()?;Sourcepub fn set_listener<L>(&mut self, listener: L) -> Result<()>where
L: AsRef<SubscriberListener>,
pub fn set_listener<L>(&mut self, listener: L) -> Result<()>where
L: AsRef<SubscriberListener>,
Sets the SubscriberListener on this
subscriber, replacing any previously set listener.
§Errors
Returns an Error if the subscriber fails to set the
listener.
§Examples
use cyclonedds::SubscriberListener;
let mut subscriber = Subscriber::new(&participant)?;
subscriber.set_listener(SubscriberListener::new())?;Sourcepub fn unset_listener(&mut self) -> Result<()>
pub fn unset_listener(&mut self) -> Result<()>
Sourcepub fn with_listener<L>(self, listener: L) -> Result<Self>where
L: AsRef<SubscriberListener>,
pub fn with_listener<L>(self, listener: L) -> Result<Self>where
L: AsRef<SubscriberListener>,
Sets the SubscriberListener on this
subscriber, consuming and returning self.
§Errors
Returns an Error if the subscriber fails to set the
listener.
§Examples
use cyclonedds::SubscriberListener;
let subscriber = Subscriber::new(&participant)?.with_listener(SubscriberListener::new())?;Trait Implementations§
Source§impl<'domain, 'participant> Debug for Subscriber<'domain, 'participant>
impl<'domain, 'participant> Debug for Subscriber<'domain, 'participant>
Source§impl Drop for Subscriber<'_, '_>
impl Drop for Subscriber<'_, '_>
Source§impl Entity for Subscriber<'_, '_>
impl Entity for Subscriber<'_, '_>
Source§fn instance_handle(&self) -> Result<InstanceHandle>
fn instance_handle(&self) -> Result<InstanceHandle>
InstanceHandle of this entity. Read more