pub struct Sender<T, C>{ /* 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>
Implementation of Telemetry Sender
impl<T, C> Sender<T, C>
Implementation of Telemetry Sender
Sourcepub fn new(
application_context: ApplicationContext,
client: C,
sender_options: Options,
) -> Result<Self, AIOProtocolError>
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
topic_pattern
is empty or whitespacetopic_pattern
,topic_namespace
, are Some and invalid or contain a token with no valid replacementtopic_token_map
isn’t empty and contains invalid key(s)/token(s)
Sourcepub async fn send(&self, message: Message<T>) -> Result<(), AIOProtocolError>
pub async fn send(&self, message: Message<T>) -> Result<(), AIOProtocolError>
Sends a Message
.
Returns Ok(())
on success, otherwise returns AIOProtocolError
.
§Arguments
message
-Message
to send
§Errors
AIOProtocolError
of kind MqttError
if
- The publish fails
- The puback reason code doesn’t indicate success.
AIOProtocolError
of kind InternalLogicError
if
- the
ApplicationHybridLogicalClock
’s counter would be incremented and overflow beyondu64::MAX
when preparing the timestamp for the message
AIOProtocolError
of kind StateInvalid
if
- the
ApplicationHybridLogicalClock
’s timestamp is too far in the future
Auto Trait Implementations§
impl<T, C> Freeze for Sender<T, C>where
C: Freeze,
impl<T, C> RefUnwindSafe for Sender<T, C>where
C: RefUnwindSafe,
T: RefUnwindSafe,
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>
impl<T, C> UnwindSafe for Sender<T, C>where
C: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more