pub struct Session { /* private fields */ }Expand description
One MQTT client for a single provisioned route pair and role.
Implementations§
Source§impl Session
impl Session
pub fn new( broker: Broker, role: Role, routes: Routes, source: impl Into<String>, ) -> Result<Self, Error>
Sourcepub fn reconnect(&mut self) -> Result<(), Error>
pub fn reconnect(&mut self) -> Result<(), Error>
Start a clean connection and provision a new last-will ID. Prior queued requests have uncertain outcomes. Reconcile them through the role engine.
Sourcepub fn disconnect(self, timeout: Duration) -> Result<(), Error>
pub fn disconnect(self, timeout: Duration) -> Result<(), Error>
Drain queued traffic within timeout and send MQTT DISCONNECT. A local
device asks the broker to publish its retained offline will. Dropping a
live session exercises the broker’s unexpected-disconnect handling.
Sourcepub fn publish(&self, target: &Target, message: &Message) -> Result<(), Error>
pub fn publish(&self, target: &Target, message: &Message) -> Result<(), Error>
Enqueue an application message at QoS 1. Only presence is retained.
Sourcepub fn poll(&mut self, timeout: Duration) -> Result<Option<SessionEvent>, Error>
pub fn poll(&mut self, timeout: Duration) -> Result<Option<SessionEvent>, Error>
Advance one MQTT event. None means a transport-only event or elapsed timeout.
A later poll resumes an in-progress connection, including its TLS and MQTT
handshakes. Route and wire rejections leave the connection usable.
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl !Sync for Session
impl !UnwindSafe for Session
impl Send for Session
impl Unpin for Session
impl UnsafeUnpin for Session
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more