Struct SubscribeBuilder
pub struct SubscribeBuilder<'a> {
cmd_tx: &'a Sender<Command>,
filter: TopicFilterBuf,
qos: QoS,
no_local: bool,
retain_as_published: bool,
retain_handling: RetainHandling,
subscription_id: Option<u32>,
}Expand description
Builder for subscribing to a topic filter with MQTT v5 options.
Obtained via MqttClient::subscribe.
Call send to send the SUBSCRIBE packet and await the
broker’s SUBACK.
Fields§
§cmd_tx: &'a Sender<Command>§filter: TopicFilterBuf§qos: QoS§no_local: bool§retain_as_published: bool§retain_handling: RetainHandling§subscription_id: Option<u32>Implementations§
§impl<'a> SubscribeBuilder<'a>
impl<'a> SubscribeBuilder<'a>
pub(crate) const fn new( cmd_tx: &'a Sender<Command>, filter: TopicFilterBuf, ) -> Self
pub const fn qos(self, qos: QoS) -> Self
pub const fn qos(self, qos: QoS) -> Self
Set the maximum QoS for messages delivered on this subscription.
pub const fn no_local(self, no_local: bool) -> Self
pub const fn no_local(self, no_local: bool) -> Self
Set the No Local option (v5): if true, the broker will not forward
messages published by this client on matching topics.
pub const fn retain_as_published(self, rap: bool) -> Self
pub const fn retain_as_published(self, rap: bool) -> Self
Set the Retain As Published option (v5): if true, the retain flag
in forwarded messages reflects the original PUBLISH, not the broker’s
retained-message state.
pub const fn retain_handling(self, rh: RetainHandling) -> Self
pub const fn retain_handling(self, rh: RetainHandling) -> Self
Set the Retain Handling option (v5): controls when retained messages are sent for this subscription.
pub const fn subscription_id(self, id: u32) -> Self
pub const fn subscription_id(self, id: u32) -> Self
Assign a Subscription Identifier (v5, property 0x0B).
The broker echoes this identifier in PUBLISH packets that match this subscription. Useful for routing messages to the correct handler.
pub async fn send(self) -> Result<Vec<ReasonCode>, Error>
pub async fn send(self) -> Result<Vec<ReasonCode>, Error>
Send the SUBSCRIBE packet and await the broker’s SUBACK.
Returns the per-filter reason codes from the SUBACK packet.
§Errors
Returns Error::ConnectionClosed if the connection is lost before
SUBACK arrives.