/// 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
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
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
pub fn handle_incoming_packet<'b>(
        &mut self,
        packet: Packet<'b>,
    ) -> Result<(Option<Notification>, Option<Packet<'static>>), StateError> {
        match packet {
            Packet::Connack(connack) => self
                .handle_incoming_connack(connack)
                .map(|()| (Notification::ConnAck.into(), None)),
            Packet::Pingresp => self.handle_incoming_pingresp(),
            Packet::Publish(publish) => self.handle_incoming_publish(publish),
            Packet::Suback(suback) => self.handle_incoming_suback(suback),
            Packet::Unsuback(pid) => self.handle_incoming_unsuback(pid),
            Packet::Puback(pid) => self.handle_incoming_puback(pid),
            Packet::Pubrec(pid) => self.handle_incoming_pubrec(pid),
            Packet::Pubrel(pid) => self.handle_incoming_pubrel(pid),
            Packet::Pubcomp(pid) => self.handle_incoming_pubcomp(pid),
            _ => {
                mqtt_log!(error, "Invalid incoming packet!");
                Ok((None, None))
            }
        }
    }
pub fn handle_incoming_packet < ' b > ( & mut self , packet : Packet < ' b > , ) -> Result < ( Option < Notification > , Option < Packet < ' static > > ) , StateError > { match packet { Packet :: Connack ( connack ) => self . handle_incoming_connack ( connack ) . map ( | ( ) | ( Notification :: ConnAck . into ( ) , None ) ) , Packet :: Pingresp => self . handle_incoming_pingresp ( ) , Packet :: Publish ( publish ) => self . handle_incoming_publish ( publish ) , Packet :: Suback ( suback ) => self . handle_incoming_suback ( suback ) , Packet :: Unsuback ( pid ) => self . handle_incoming_unsuback ( pid ) , Packet :: Puback ( pid ) => self . handle_incoming_puback ( pid ) , Packet :: Pubrec ( pid ) => self . handle_incoming_pubrec ( pid ) , Packet :: Pubrel ( pid ) => self . handle_incoming_pubrel ( pid ) , Packet :: Pubcomp ( pid ) => self . handle_incoming_pubcomp ( pid ) , _ => { mqtt_log ! ( error " " ) ; Ok ( ( None , None ) ) } } }
Consolidates handling of all incoming mqtt packets.
Consolidates handling of all incoming mqtt packets .
&mut self
packet
Packet<'b>