Struct EventLoopHandle
pub struct EventLoopHandle {
shutdown_tx: Sender<()>,
task: JoinHandle<()>,
}Expand description
Owns the connection event loop and controls its lifecycle.
Returned by ClientBuilder::start next to
the MqttClient. Client handles clone freely and only
issue operations; this handle is unique, and the event loop runs exactly as
long as it lives: dropping every client handle does not stop the session.
Call stop for a graceful shutdown. Dropping the handle
without calling it also shuts the event loop down, but without sending a
DISCONNECT packet, so the broker treats the connection as lost and
publishes the will (if one is configured).
Fields§
§shutdown_tx: Sender<()>§task: JoinHandle<()>Implementations§
§impl EventLoopHandle
impl EventLoopHandle
pub(crate) const fn new(shutdown_tx: Sender<()>, task: JoinHandle<()>) -> Self
pub async fn stop(self)
pub async fn stop(self)
Sends a graceful DISCONNECT and waits for the event loop to exit.
The shutdown signal is delivered out of band, so it takes effect even while the event loop has paused command intake for backpressure. Commands already accepted are still applied before the DISCONNECT is sent. Completes once the event loop has fully exited (connection closed, journal writer flushed); if it already exited on its own, completes immediately.
Auto Trait Implementations§
impl Freeze for EventLoopHandle
impl !RefUnwindSafe for EventLoopHandle
impl Send for EventLoopHandle
impl Sync for EventLoopHandle
impl Unpin for EventLoopHandle
impl !UnwindSafe for EventLoopHandle
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