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. The broker then treats the connection as lost and
publishes the will (if one is configured).
Fields§
§shutdown_tx: Sender<()>§task: JoinHandle<()>Implementations§
Source§impl EventLoopHandle
impl EventLoopHandle
Sourcepub 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.
§Panics
Resumes the panic of the event loop if it panicked.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EventLoopHandle
impl !UnwindSafe for EventLoopHandle
impl Freeze for EventLoopHandle
impl Send for EventLoopHandle
impl Sync for EventLoopHandle
impl Unpin for EventLoopHandle
impl UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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