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

Telemetry Sender struct

§Example

let sender_options = telemetry::sender::OptionsBuilder::default()
  .topic_pattern("test/telemetry")
  .topic_namespace("test_namespace")
  .topic_token_map(HashMap::new())
  .build().unwrap();
let sender: telemetry::Sender<Vec<u8>, _> = telemetry::Sender::new(application_context, mqtt_session.create_managed_client(), sender_options).unwrap();
let telemetry_message = telemetry::sender::MessageBuilder::default()
  .payload(Vec::new()).unwrap()
  .qos(QoS::AtLeastOnce)
  .build().unwrap();
// let result = sender.send(telemetry_message).await.unwrap();

Implementations§

Source§

impl<T, C> Sender<T, C>
where T: PayloadSerialize, C: ManagedClient + Send + Sync + 'static,

Implementation of Telemetry Sender

Source

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

Creates a new Sender.

§Arguments
  • application_context - ApplicationContext that the telemetry sender is part of.
  • client - The MQTT client to use for telemetry communication.
  • sender_options - Configuration options.

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

§Errors

AIOProtocolError of kind ConfigurationInvalid if

Source

pub async fn send(&self, message: Message<T>) -> Result<(), AIOProtocolError>

Sends a Message.

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

§Arguments
§Errors

AIOProtocolError of kind MqttError if

  • The publish fails
  • The puback reason code doesn’t indicate success.

AIOProtocolError of kind InternalLogicError if

AIOProtocolError of kind StateInvalid if

Auto Trait Implementations§

§

impl<T, C> Freeze for Sender<T, C>
where C: Freeze,

§

impl<T, C> RefUnwindSafe for Sender<T, C>

§

impl<T, C> Send for Sender<T, C>
where T: Send,

§

impl<T, C> Sync for Sender<T, C>
where T: Sync,

§

impl<T, C> Unpin for Sender<T, C>
where C: Unpin, T: Unpin,

§

impl<T, C> UnwindSafe for Sender<T, C>
where C: 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