spoke/packet/client/incoming
Incoming packets for a MQTT client
Types
Represents all the valid incoming packets for an MQTT client.
pub type Packet {
ConnAck(Result(packet.SessionPresence, packet.ConnectError))
Publish(packet.PublishData)
PubAck(packet_id: Int)
PubRec(packet_id: Int)
PubRel(packet_id: Int)
PubComp(packet_id: Int)
SubAck(
packet_id: Int,
return_codes: List(Result(packet.QoS, Nil)),
)
UnsubAck(packet_id: Int)
PingResp
}
Constructors
-
ConnAck(Result(packet.SessionPresence, packet.ConnectError))
-
Publish(packet.PublishData)
-
PubAck(packet_id: Int)
-
PubRec(packet_id: Int)
-
PubRel(packet_id: Int)
-
PubComp(packet_id: Int)
-
SubAck( packet_id: Int, return_codes: List(Result(packet.QoS, Nil)), )
-
UnsubAck(packet_id: Int)
-
PingResp
Values
pub fn decode_packet(
bytes: BitArray,
) -> Result(#(Packet, BitArray), packet.DecodeError)
Decodes a single packet from a chunk of binary data. Returns the decoded packet and the leftover data, or the first error if the data is invalid.
pub fn decode_packets(
bytes: BitArray,
) -> Result(#(List(Packet), BitArray), packet.DecodeError)
Decodes all packets from a chunk of binary data.
Returns a list of decoded packets and the leftover data,
or the first error if the data is invalid.
Will never return Error(DataTooShort)
,
but might return an empty list and the input data.