pub struct EventLoop {
pub options: MqttOptions,
pub state: MqttState,
/* private fields */
}Expand description
Eventloop with all the state of a connection
Fields§
§options: MqttOptionsOptions of the current mqtt connection
state: MqttStateCurrent state of the connection
Implementations§
Source§impl EventLoop
impl EventLoop
Sourcepub fn new(options: MqttOptions, cap: usize) -> Self
pub fn new(options: MqttOptions, cap: usize) -> Self
New MQTT EventLoop
When connection encounters critical errors (like auth failure), user has a choice to
access and update options, state and requests.
Sourcepub fn clean(&mut self)
pub fn clean(&mut self)
Last session might contain packets which aren’t acked. MQTT says these packets should be republished in the next session. Move pending messages from state to eventloop, drops the underlying network connection and clears the keepalive timeout if any.
NOTE: Use only when EventLoop is blocked on network and unable to immediately handle disconnect. Pending requests are managed internally by the event loop. Use
pending_lenorpending_is_emptyfor observation-only checks.
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Number of pending requests queued for retransmission.
Sourcepub fn pending_is_empty(&self) -> bool
pub fn pending_is_empty(&self) -> bool
Returns true when there are no pending requests queued for retransmission.
Sourcepub fn drain_pending_as_failed(&mut self, reason: NoticeFailureReason) -> usize
pub fn drain_pending_as_failed(&mut self, reason: NoticeFailureReason) -> usize
Drains pending retransmission queue and fails tracked notices with the given reason.
Returns the number of pending requests removed from the queue.
Sourcepub fn reset_session_state(&mut self)
pub fn reset_session_state(&mut self)
Clears eventloop and state tracking bound to a previous session.
Sourcepub async fn poll(&mut self) -> Result<Event, ConnectionError>
pub async fn poll(&mut self) -> Result<Event, ConnectionError>
Yields Next notification or outgoing request and periodically pings the broker. Continuing to poll will reconnect to the broker if there is a disconnection. NOTE Don’t block this while iterating
§Errors
Returns a ConnectionError if connecting, reading, writing, or
protocol handling fails.