pub struct MessageBuilder<T: PayloadSerialize> { /* private fields */ }
Expand description
Builder for Message
.
Implementations§
Source§impl<T: PayloadSerialize + Clone> MessageBuilder<T>
impl<T: PayloadSerialize + Clone> MessageBuilder<T>
Sourcepub fn qos<VALUE: Into<QoS>>(&mut self, value: VALUE) -> &mut Self
pub fn qos<VALUE: Into<QoS>>(&mut self, value: VALUE) -> &mut Self
Quality of Service of the telemetry message. Can only be AtMostOnce
or AtLeastOnce
.
Sourcepub fn custom_user_data<VALUE: Into<Vec<(String, String)>>>(
&mut self,
value: VALUE,
) -> &mut Self
pub fn custom_user_data<VALUE: Into<Vec<(String, String)>>>( &mut self, value: VALUE, ) -> &mut Self
User data that will be set as custom MQTT User Properties on the telemetry message.
Can be used to pass additional metadata to the receiver.
Default is an empty Vec
.
Sourcepub fn topic_tokens<VALUE: Into<HashMap<String, String>>>(
&mut self,
value: VALUE,
) -> &mut Self
pub fn topic_tokens<VALUE: Into<HashMap<String, String>>>( &mut self, value: VALUE, ) -> &mut Self
Topic token keys/values to be replaced into the publish topic of the telemetry message.
Sourcepub fn cloud_event<VALUE: Into<Option<CloudEvent>>>(
&mut self,
value: VALUE,
) -> &mut Self
pub fn cloud_event<VALUE: Into<Option<CloudEvent>>>( &mut self, value: VALUE, ) -> &mut Self
Cloud event of the telemetry message.
Sourcepub fn retain<VALUE: Into<bool>>(&mut self, value: VALUE) -> &mut Self
pub fn retain<VALUE: Into<bool>>(&mut self, value: VALUE) -> &mut Self
Indicates whether the message should be retained or not.
Source§impl<T: PayloadSerialize> MessageBuilder<T>
impl<T: PayloadSerialize> MessageBuilder<T>
Sourcepub fn payload(&mut self, payload: T) -> Result<&mut Self, AIOProtocolError>
pub fn payload(&mut self, payload: T) -> Result<&mut Self, AIOProtocolError>
Add a payload to the telemetry message. Validates successful serialization of the payload.
§Errors
AIOProtocolError
of kind PayloadInvalid
if serialization of the payload fails
AIOProtocolError
of kind ConfigurationInvalid
if the content type is not valid utf-8
Sourcepub fn message_expiry(&mut self, message_expiry: Duration) -> &mut Self
pub fn message_expiry(&mut self, message_expiry: Duration) -> &mut Self
Set the message expiry for the telemetry.
Note: Will be rounded up to the nearest second.
Trait Implementations§
Source§impl<T: Clone + PayloadSerialize> Clone for MessageBuilder<T>
impl<T: Clone + PayloadSerialize> Clone for MessageBuilder<T>
Source§fn clone(&self) -> MessageBuilder<T>
fn clone(&self) -> MessageBuilder<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more