SubscribeBuilder

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>

pub(crate) const fn new( cmd_tx: &'a Sender<Command>, filter: TopicFilterBuf, ) -> 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

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

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

Set the Retain Handling option (v5): controls when retained messages are sent for this subscription.

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>

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.

Auto Trait Implementations§

§

impl<'a> Freeze for SubscribeBuilder<'a>

§

impl<'a> RefUnwindSafe for SubscribeBuilder<'a>

§

impl<'a> Send for SubscribeBuilder<'a>

§

impl<'a> Sync for SubscribeBuilder<'a>

§

impl<'a> Unpin for SubscribeBuilder<'a>

§

impl<'a> UnwindSafe for SubscribeBuilder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.