pub struct MqttState {
pub await_pingresp: bool,
pub collision_ping_count: usize,
pub events: VecDeque<Event>,
pub manual_acks: bool,
/* private fields */
}
Expand description
State of the mqtt connection.
Fields§
§await_pingresp: bool
Status of last ping
collision_ping_count: usize
Collision ping count. Collisions stop user requests which inturn trigger pings. Multiple pings without resolving collisions will result in error
events: VecDeque<Event>
Buffered incoming packets
manual_acks: bool
Indicates if acknowledgements should be send immediately
Implementations§
Source§impl MqttState
impl MqttState
Sourcepub fn new(max_inflight: u16, manual_acks: bool) -> Self
pub fn new(max_inflight: u16, manual_acks: bool) -> Self
Creates new mqtt state. Same state should be used during a connection for persistent sessions while new state should instantiated for clean sessions
Sourcepub fn clean(&mut self) -> Vec<(NoticeTx, Request)>
pub fn clean(&mut self) -> Vec<(NoticeTx, Request)>
Returns inflight outgoing packets and clears internal queues
pub fn inflight(&self) -> u16
Sourcepub fn handle_outgoing_packet(
&mut self,
tx: NoticeTx,
request: Request,
) -> Result<Option<Packet>, StateError>
pub fn handle_outgoing_packet( &mut self, tx: NoticeTx, request: Request, ) -> Result<Option<Packet>, StateError>
Consolidates handling of all outgoing mqtt packet logic. Returns a packet which should be put on to the network by the eventloop
Sourcepub fn handle_incoming_packet(
&mut self,
packet: Incoming,
) -> Result<Option<Packet>, StateError>
pub fn handle_incoming_packet( &mut self, packet: Incoming, ) -> Result<Option<Packet>, StateError>
Consolidates handling of all incoming mqtt packets. Returns a Notification
which for the
user to consume and Packet
which for the eventloop to put on the network
E.g For incoming QoS1 publish packet, this method returns (Publish, Puback). Publish packet will
be forwarded to user and Pubck packet will be written to network