pub struct Session(/* private fields */);
Expand description
Client that manages connections over a single MQTT session.
Use this centrally in an application to control the session and to create
instances of SessionManagedClient
and SessionExitHandle
.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(options: SessionOptions) -> Result<Self, SessionConfigError>
pub fn new(options: SessionOptions) -> Result<Self, SessionConfigError>
Create a new Session
with the provided options structure.
§Errors
Returns a SessionConfigError
if there are errors using the session options.
Sourcepub fn create_exit_handle(&self) -> SessionExitHandle
pub fn create_exit_handle(&self) -> SessionExitHandle
Return a new instance of SessionExitHandle
that can be used to end this Session
Sourcepub fn create_connection_monitor(&self) -> SessionConnectionMonitor
pub fn create_connection_monitor(&self) -> SessionConnectionMonitor
Return a new instance of SessionConnectionMonitor
that can be used to monitor the connection state
Sourcepub fn create_managed_client(&self) -> SessionManagedClient
pub fn create_managed_client(&self) -> SessionManagedClient
Return a new instance of SessionManagedClient
that can be used to send and receive messages
Sourcepub async fn run(self) -> Result<(), SessionError>
pub async fn run(self) -> Result<(), SessionError>
Begin running the Session
.
Blocks until either a session exit or a fatal connection error is encountered.
§Errors
Returns a SessionError
if the session encounters a fatal error and ends.