Struct SubscribeBuilder
pub struct SubscribeBuilder {
cmd_tx: Sender<Command>,
subscriptions: Vec<Subscription>,
subscription_id: Option<u32>,
}Expand description
Builder for subscribing to one or more topic filters.
Obtained via MqttClient::subscribe.
Call send to get a SubscribeFuture that can be awaited
for SUBACK, or converted to a QueuedSubscribeFuture via
SubscribeFuture::queued to resolve as soon as the subscription is
recorded locally.
Fields§
§cmd_tx: Sender<Command>§subscriptions: Vec<Subscription>§subscription_id: Option<u32>Implementations§
§impl SubscribeBuilder
impl SubscribeBuilder
pub(crate) fn new(cmd_tx: Sender<Command>, subscription: Subscription) -> Self
pub fn and(self, subscription: Subscription) -> Self
pub fn and(self, subscription: Subscription) -> Self
Adds an additional subscription to this batch.
All subscriptions in the batch are sent in a single SUBSCRIBE packet.
pub const fn subscription_id(self, id: u32) -> Self
pub const fn subscription_id(self, id: u32) -> Self
Assigns a Subscription Identifier (v5, property 0x0B).
The broker echoes this identifier in PUBLISH packets that match any filter in this batch.
pub fn send(self) -> SubscribeFuture ⓘ
pub fn send(self) -> SubscribeFuture ⓘ
Returns a SubscribeFuture that drives the SUBSCRIBE to completion.
No work is done until the future is first polled. A permit on the
command channel is reserved before the Command is built, so memory
is only allocated once back-pressure is released.
Await the future to wait for SUBACK, or call
SubscribeFuture::queued to convert it into a
QueuedSubscribeFuture that resolves as soon as the subscription is
recorded locally.
Auto Trait Implementations§
impl Freeze for SubscribeBuilder
impl RefUnwindSafe for SubscribeBuilder
impl Send for SubscribeBuilder
impl Sync for SubscribeBuilder
impl Unpin for SubscribeBuilder
impl UnwindSafe for SubscribeBuilder
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