spoke/packet/server/incoming
Incoming packets for a MQTT server.
Types
Represents all the valid incoming packets for an MQTT server.
pub type Packet {
Connect(packet.ConnectOptions)
Publish(packet.PublishData)
PubAck(packet_id: Int)
PubRec(packet_id: Int)
PubRel(packet_id: Int)
PubComp(packet_id: Int)
Subscribe(packet_id: Int, topic: List(packet.SubscribeRequest))
Unsubscribe(packet_id: Int, topics: List(String))
PingReq
Disconnect
}
Constructors
-
Connect(packet.ConnectOptions) -
Publish(packet.PublishData) -
PubAck(packet_id: Int) -
PubRec(packet_id: Int) -
PubRel(packet_id: Int) -
PubComp(packet_id: Int) -
Subscribe(packet_id: Int, topic: List(packet.SubscribeRequest)) -
Unsubscribe(packet_id: Int, topics: List(String)) -
PingReq -
Disconnect
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.