pub struct Receiver<T, C>
where T: PayloadSerialize + Send + Sync + 'static, C: ManagedClient + Clone + Send + Sync + 'static, C::PubReceiver: Send + Sync + 'static,
{ /* private fields */ }
Expand description

Telemetry Receiver struct

§Example

let receiver_options = telemetry::receiver::OptionsBuilder::default()
 .topic_pattern("test/telemetry")
 .build().unwrap();
let mut receiver: telemetry::Receiver<Vec<u8>, _> = telemetry::Receiver::new(application_context, mqtt_session.create_managed_client(), receiver_options).unwrap();
// let telemetry_message = receiver.recv().await.unwrap();

Implementations§

Source§

impl<T, C> Receiver<T, C>
where T: PayloadSerialize + Send + Sync + 'static, C: ManagedClient + Clone + Send + Sync + 'static, C::PubReceiver: Send + Sync + 'static,

Implementation of a Telemetry Sender

Source

pub fn new( application_context: ApplicationContext, client: C, receiver_options: Options, ) -> Result<Self, AIOProtocolError>

Creates a new Receiver.

§Arguments
  • application_context - ApplicationContext that the telemetry receiver is part of.
  • client - [ManagedClient] to use for telemetry communication.
  • receiver_options - Options to configure the telemetry receiver.

Returns Ok(Receiver) on success, otherwise returnsAIOProtocolError.

§Errors

AIOProtocolError of kind ConfigurationInvalid

Source

pub async fn shutdown(&mut self) -> Result<(), AIOProtocolError>

Shutdown the Receiver. Unsubscribes from the telemetry topic if subscribed.

Note: If this method is called, the Receiver will no longer receive telemetry messages from the MQTT client, any messages that have not been processed can still be received by the receiver. If the method returns an error, it may be called again to attempt the unsubscribe again.

Returns Ok(()) on success, otherwise returns AIOProtocolError.

§Errors

AIOProtocolError of kind ClientError if the unsubscribe fails or if the unsuback reason code doesn’t indicate success.

Source

pub async fn recv( &mut self, ) -> Option<Result<(Message<T>, Option<AckToken>), AIOProtocolError>>

Receives a telemetry message or None if there will be no more messages. If there are messages:

A received message can be acknowledged via the [AckToken] by calling [AckToken::ack] or dropping the [AckToken].

Will also subscribe to the telemetry topic if not already subscribed.

§Errors

AIOProtocolError of kind ClientError if the subscribe fails or if the suback reason code doesn’t indicate success.

Trait Implementations§

Source§

impl<T, C> Drop for Receiver<T, C>
where T: PayloadSerialize + Send + Sync + 'static, C: ManagedClient + Clone + Send + Sync + 'static, C::PubReceiver: Send + Sync + 'static,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, C> Freeze for Receiver<T, C>
where C: Freeze, <C as ManagedClient>::PubReceiver: Freeze,

§

impl<T, C> RefUnwindSafe for Receiver<T, C>
where C: RefUnwindSafe, <C as ManagedClient>::PubReceiver: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, C> Send for Receiver<T, C>

§

impl<T, C> Sync for Receiver<T, C>

§

impl<T, C> Unpin for Receiver<T, C>
where C: Unpin, <C as ManagedClient>::PubReceiver: Unpin, T: Unpin,

§

impl<T, C> UnwindSafe for Receiver<T, C>
where C: UnwindSafe, <C as ManagedClient>::PubReceiver: UnwindSafe, T: UnwindSafe,

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> 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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V