Skip to main content

ReaderListener

Struct ReaderListener 

Source
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,

Source

pub fn new() -> Self

Creates a new ReaderListener<T> with no callbacks registered.

§Examples
use cyclonedds::listener::ReaderListener;

let listener = ReaderListener::<Data>::new();
Source

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);
});
Source

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:?}");
});
Source

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:?}");
});
Source

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);
    });
Source

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);
    },
);
Source

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:?}");
    },
);
Source

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,

Source§

fn as_ref(&self) -> &ReaderListener<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Clone for ReaderListener<T>
where T: Topicable + Clone,

Source§

fn clone(&self) -> ReaderListener<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for ReaderListener<T>
where T: Topicable + Copy,

Source§

impl<T> Debug for ReaderListener<T>
where T: Topicable + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for ReaderListener<T>
where T: Topicable,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ReaderListener<T>

§

impl<T> RefUnwindSafe for ReaderListener<T>

§

impl<T> Send for ReaderListener<T>

§

impl<T> Sync for ReaderListener<T>

§

impl<T> Unpin for ReaderListener<T>

§

impl<T> UnsafeUnpin for ReaderListener<T>

§

impl<T> UnwindSafe for ReaderListener<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.