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.
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>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: PayloadSerialize + Clone> Default for MessageBuilder<T>
impl<T: PayloadSerialize + Clone> Default for MessageBuilder<T>
Auto Trait Implementations§
impl<T> Freeze for MessageBuilder<T>
impl<T> RefUnwindSafe for MessageBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for MessageBuilder<T>where
T: Send,
impl<T> Sync for MessageBuilder<T>where
T: Sync,
impl<T> Unpin for MessageBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for MessageBuilder<T>where
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