Struct PublishBuilder
pub struct PublishBuilder {
cmd_tx: Sender<Command>,
topic: TopicBuf,
payload: Vec<u8>,
qos: QoS,
retain: bool,
properties: PublishOptions,
}Expand description
Builder for publishing a message with optional MQTT v5 properties.
Obtained via MqttClient::publish.
Call send to obtain a PublishFuture. The future is
lazy: no work is done until it is polled.
Fields§
§cmd_tx: Sender<Command>§topic: TopicBuf§payload: Vec<u8>§qos: QoS§retain: bool§properties: PublishOptionsImplementations§
§impl PublishBuilder
impl PublishBuilder
pub(crate) fn new( cmd_tx: Sender<Command>, topic: TopicBuf, payload: Vec<u8>, qos: QoS, ) -> Self
pub fn content_type(self, ct: MqttString) -> Self
pub fn content_type(self, ct: MqttString) -> Self
Sets the MIME content type (property 0x03).
pub fn response_topic(self, topic: TopicBuf) -> Self
pub fn response_topic(self, topic: TopicBuf) -> Self
Sets the response topic for request/response flows (property 0x08).
pub fn correlation_data(self, data: MqttBytesBuf) -> Self
pub fn correlation_data(self, data: MqttBytesBuf) -> Self
Sets correlation data for request/response flows (property 0x09).
pub const fn message_expiry(self, seconds: u32) -> Self
pub const fn message_expiry(self, seconds: u32) -> Self
Sets the message expiry interval in seconds (property 0x02).
pub const fn payload_format(self, format: PayloadFormat) -> Self
pub const fn payload_format(self, format: PayloadFormat) -> Self
Indicate whether the payload is UTF-8 encoded (property 0x01).
pub fn user_property(self, key: MqttString, value: MqttString) -> Self
pub fn user_property(self, key: MqttString, value: MqttString) -> Self
Adds a user property key-value pair (property 0x26).
May be called multiple times.
pub fn send(self) -> PublishFuture ⓘ
pub fn send(self) -> PublishFuture ⓘ
Returns a lazy future representing the publish.
No work is done until the future is polled. Awaiting it drives the
publish to broker acknowledgement (PUBACK for QoS 1, PUBCOMP for
QoS 2). For QoS 0 it resolves once the bytes have been written.
Call PublishFuture::queued on the returned future if you only need
to wait for the message to be persisted locally.
Auto Trait Implementations§
impl Freeze for PublishBuilder
impl RefUnwindSafe for PublishBuilder
impl Send for PublishBuilder
impl Sync for PublishBuilder
impl Unpin for PublishBuilder
impl UnwindSafe for PublishBuilder
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more