pub struct MqttState {
pub await_pingresp: bool,
pub collision_ping_count: usize,
pub collision: Option<Publish>,
pub events: VecDeque<Event>,
pub write: BytesMut,
pub manual_acks: bool,
pub broker_topic_alias_max: u16,
pub max_outgoing_packet_size: Option<u32>,
/* private fields */
}Expand description
State of the mqtt connection.
Fields§
§await_pingresp: boolStatus of last ping
collision_ping_count: usizeCollision ping count. Collisions stop user requests which inturn trigger pings. Multiple pings without resolving collisions will result in error
collision: Option<Publish>Last collision due to broker not acking in order
events: VecDeque<Event>Buffered incoming packets
write: BytesMutWrite buffer
manual_acks: boolIndicates if acknowledgements should be send immediately
broker_topic_alias_max: u16topic_alias_maximum RECEIVED via connack packet
max_outgoing_packet_size: Option<u32>The broker’s max_packet_size received via connack
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<Request>
pub fn clean(&mut self) -> Vec<Request>
Returns inflight outgoing packets and clears internal queues
pub fn inflight(&self) -> u16
Sourcepub fn handle_outgoing_packet(
&mut self,
request: Request,
) -> Result<(), StateError>
pub fn handle_outgoing_packet( &mut self, request: Request, ) -> Result<(), 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<(), StateError>
pub fn handle_incoming_packet( &mut self, packet: Incoming, ) -> Result<(), 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