pub struct SessionExitHandle(/* private fields */);
Expand description
Handle used to end an MQTT session.
PLEASE NOTE WELL This struct’s API is designed around negotiating a graceful exit with the MQTT broker. However, this is not actually possible right now due to a bug in underlying MQTT library.
Implementations§
Source§impl SessionExitHandle
impl SessionExitHandle
Sourcepub async fn try_exit(&self) -> Result<(), SessionExitError>
pub async fn try_exit(&self) -> Result<(), SessionExitError>
Attempt to gracefully end the MQTT session running in the Session
that created this handle.
This will cause the Session::run()
method to return.
Note that a graceful exit requires the Session
to be connected to the broker.
If the Session
is not connected, this method will return an error.
If the Session
connection has been recently lost, the Session
may not yet realize this,
and it can take until up to the keep-alive interval for the Session
to realize it is disconnected,
after which point this method will return an error. Under this circumstance, the attempt was still made,
and may eventually succeed even if this method returns the error
§Errors
SessionExitError
of kindSessionExitErrorKind::Detached
if the Session no longer exists.SessionExitError
of kindSessionExitErrorKind::BrokerUnavailable
if the Session is not connected to the broker.
Sourcepub async fn try_exit_timeout(
&self,
timeout: Duration,
) -> Result<(), SessionExitError>
pub async fn try_exit_timeout( &self, timeout: Duration, ) -> Result<(), SessionExitError>
Attempt to gracefully end the MQTT session running in the Session
that created this handle.
This will cause the Session::run()
method to return.
Note that a graceful exit requires the Session
to be connected to the broker.
If the Session
is not connected, this method will return an error.
If the Session
connection has been recently lost, the Session
may not yet realize this,
and it can take until up to the keep-alive interval for the Session
to realize it is disconnected,
after which point this method will return an error. Under this circumstance, the attempt was still made,
and may eventually succeed even if this method returns the error
If the graceful Session
exit attempt does not complete within the specified timeout, this method
will return an error.
§Arguments
timeout
- The duration to wait for the graceful exit to complete before returning an error.
§Errors
SessionExitError
of kindSessionExitErrorKind::Detached
if the Session no longer exists.SessionExitError
of kindSessionExitErrorKind::BrokerUnavailable
if the Session is not connected to the broker within the specified timeout interval.
Sourcepub async fn exit_force(&self) -> bool
pub async fn exit_force(&self) -> bool
Forcefully end the MQTT session running in the Session
that created this handle.
This will cause the Session::run()
method to return.
The Session
will be granted a period of 1 second to attempt a graceful exit before
forcing the exit. If the exit is forced, the broker will not be aware the MQTT session
has ended.
Returns true if the exit was graceful, and false if the exit was forced.
Trait Implementations§
Source§impl Clone for SessionExitHandle
impl Clone for SessionExitHandle
Source§fn clone(&self) -> SessionExitHandle
fn clone(&self) -> SessionExitHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more