pub struct ReaderListener<T>where
T: Topicable,{ /* private fields */ }Expand description
Listener attached to a Reader<T>.
Implementations§
Source§impl<T> ReaderListener<T>where
T: Topicable,
impl<T> ReaderListener<T>where
T: Topicable,
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ReaderListener<T> with no callbacks registered.
§Examples
use cyclonedds::listener::ReaderListener;
let listener = ReaderListener::<Data>::new();Sourcepub fn with_sample_lost(
self,
callback: fn(&Reader<'_, '_, '_, T>, SampleLost),
) -> Self
pub fn with_sample_lost( self, callback: fn(&Reader<'_, '_, '_, T>, SampleLost), ) -> Self
Sets a callback for the SampleLost status
event.
The callback receives a SampleLost metadata struct.
Fired when a sample is lost, meaning it was never received by this
reader due to resource limits or QoS constraints.
§Examples
use cyclonedds::listener::ReaderListener;
let listener = ReaderListener::<Data>::new().with_sample_lost(|reader, sample_lost| {
println!("samples lost: {}", sample_lost.total.count);
});Sourcepub fn with_data_available(self, callback: fn(&Reader<'_, '_, '_, T>)) -> Self
pub fn with_data_available(self, callback: fn(&Reader<'_, '_, '_, T>)) -> Self
Sets a callback for the DataAvailable status
event.
Fired when new data is available to be peeked,
read, or taken from
this reader.
§Examples
use cyclonedds::listener::ReaderListener;
let listener = ReaderListener::<Data>::new().with_data_available(|reader| {
println!("data available on {reader:?}");
});Sourcepub fn with_sample_rejected(
self,
callback: fn(&Reader<'_, '_, '_, T>, SampleRejected),
) -> Self
pub fn with_sample_rejected( self, callback: fn(&Reader<'_, '_, '_, T>, SampleRejected), ) -> Self
Sets a callback for the
SampleRejected status event.
The callback receives a SampleRejected metadata
struct.
Fired when an incoming sample is rejected due to
ResourceLimits.
§Examples
use cyclonedds::listener::ReaderListener;
let listener = ReaderListener::<Data>::new().with_sample_rejected(|reader, status| {
println!("sample rejected: {status:?}");
});Sourcepub fn with_liveliness_changed(
self,
callback: fn(&Reader<'_, '_, '_, T>, LivelinessChanged),
) -> Self
pub fn with_liveliness_changed( self, callback: fn(&Reader<'_, '_, '_, T>, LivelinessChanged), ) -> Self
Sets a callback for the
LivelinessChanged status event.
The callback receives a
LivelinessChanged metadata struct.
Fired when the Liveliness of a
matched writer changes, i.e. a writer becomes active or inactive.
§Examples
use cyclonedds::listener::ReaderListener;
let listener =
ReaderListener::<Data>::new().with_liveliness_changed(|reader, liveliness_changed| {
println!("active writers: {}", liveliness_changed.alive.count);
});Sourcepub fn with_requested_deadline_missed(
self,
callback: fn(&Reader<'_, '_, '_, T>, RequestedDeadlineMissed),
) -> Self
pub fn with_requested_deadline_missed( self, callback: fn(&Reader<'_, '_, '_, T>, RequestedDeadlineMissed), ) -> Self
Sets a callback for the
RequestedDeadlineMissed status
event.
The callback receives a
RequestedDeadlineMissed metadata struct.
Fired when a sample is not received within the
Deadline period offered by a matched
writer.
§Examples
use cyclonedds::listener::ReaderListener;
let listener = ReaderListener::<Data>::new().with_requested_deadline_missed(
|reader, requested_deadline_missed| {
println!("deadline missed: {}", requested_deadline_missed.total.count);
},
);Sourcepub fn with_requested_incompatible_qos(
self,
callback: fn(&Reader<'_, '_, '_, T>, RequestedIncompatibleQoS),
) -> Self
pub fn with_requested_incompatible_qos( self, callback: fn(&Reader<'_, '_, '_, T>, RequestedIncompatibleQoS), ) -> Self
Sets a callback for the
RequestedIncompatibleQoS status
event.
The callback receives a
RequestedIncompatibleQoS metadata struct.
Fired when a writer is discovered whose offered QoS is
incompatible with this reader’s requested QoS.
§Examples
use cyclonedds::listener::ReaderListener;
let listener = ReaderListener::<Data>::new().with_requested_incompatible_qos(
|reader, requested_incompatible_qos| {
println!("incompatible QoS: {requested_incompatible_qos:?}");
},
);Sourcepub fn with_subscription_matched(
self,
callback: fn(&Reader<'_, '_, '_, T>, SubscriptionMatched),
) -> Self
pub fn with_subscription_matched( self, callback: fn(&Reader<'_, '_, '_, T>, SubscriptionMatched), ) -> Self
Sets a callback for the
SubscriptionMatched status event
status event.
The callback receives a
SubscriptionMatched metadata struct.
Fired when a writer matching this reader’s topic and QoS
is discovered or lost.
§Examples
use cyclonedds::listener::ReaderListener;
let listener =
ReaderListener::<Data>::new().with_subscription_matched(|reader, subscription_matched| {
println!("matched writers: {}", subscription_matched.current.count);
});Trait Implementations§
Source§impl<T> AsRef<ReaderListener<T>> for ReaderListener<T>where
T: Topicable,
impl<T> AsRef<ReaderListener<T>> for ReaderListener<T>where
T: Topicable,
Source§fn as_ref(&self) -> &ReaderListener<T>
fn as_ref(&self) -> &ReaderListener<T>
Source§impl<T> Clone for ReaderListener<T>
impl<T> Clone for ReaderListener<T>
Source§fn clone(&self) -> ReaderListener<T>
fn clone(&self) -> ReaderListener<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more