spoke/packet
Data types shared between incoming and outgoing packets and/or server and client packets.
Types
Authentication options. MQTT does not allow using only a password (MQTT 5.4.1)
pub type AuthOptions {
AuthOptions(
username: String,
password: option.Option(BitArray),
)
}
Constructors
-
AuthOptions(username: String, password: option.Option(BitArray))
The data in a CONNACK packet (MQTT 3.2)
pub type ConnAckResult =
Result(SessionPresence, ConnectError)
The error values of the CONNECT return code (MQTT 3.2.2.3)
pub type ConnectError {
UnacceptableProtocolVersion
IdentifierRefused
ServerUnavailable
BadUsernameOrPassword
NotAuthorized
}
Constructors
-
UnacceptableProtocolVersion
The Server does not support the level of the MQTT protocol requested by the Client
-
IdentifierRefused
The Client identifier is correct UTF-8 but not allowed by the Server
-
ServerUnavailable
The Network Connection has been made but the MQTT service is unavailable
-
BadUsernameOrPassword
The data in the user name or password is malformed
-
NotAuthorized
The options passed in CONNECT packets (MQTT 3.1)
pub type ConnectOptions {
ConnectOptions(
clean_session: Bool,
client_id: String,
keep_alive_seconds: Int,
auth: option.Option(AuthOptions),
will: option.Option(#(MessageData, QoS)),
)
}
Constructors
-
ConnectOptions( clean_session: Bool, client_id: String, keep_alive_seconds: Int, auth: option.Option(AuthOptions), will: option.Option(#(MessageData, QoS)), )
An error that can be encountered during decoding.
pub type DecodeError {
InvalidPacketIdentifier(Int)
DataTooShort
InvalidData
InvalidUTF8
InvalidQoS
VarIntTooLarge
}
Constructors
-
InvalidPacketIdentifier(Int)
The packet identifier in the header was not valid.
-
DataTooShort
The data being decoded did not contain the entire packet.
-
InvalidData
The data contained values that are specified as invalid, e.g. non-zero reserved bits.
-
InvalidUTF8
A string in a packet contained data that wasn’t valid UTF-8.
-
InvalidQoS
A QoS value wasn’t in the valid range.
-
VarIntTooLarge
A variable-length integer was too long.
The core data of a message, which is not dependent on the session state or QoS.
pub type MessageData {
MessageData(topic: String, payload: BitArray, retain: Bool)
}
Constructors
-
MessageData(topic: String, payload: BitArray, retain: Bool)
Data for a published message. QoS0 can never have dup or packet id, thus the variants. This is slightly clunky, but safe. (MQTT 3.3)
pub type PublishData {
PublishDataQoS0(MessageData)
PublishDataQoS1(
message: MessageData,
dup: Bool,
packet_id: Int,
)
PublishDataQoS2(
message: MessageData,
dup: Bool,
packet_id: Int,
)
}
Constructors
-
PublishDataQoS0(MessageData)
-
PublishDataQoS1(message: MessageData, dup: Bool, packet_id: Int)
-
PublishDataQoS2(message: MessageData, dup: Bool, packet_id: Int)
The MQTT Quality of service level (MQTT 4.3)
pub type QoS {
QoS0
QoS1
QoS2
}
Constructors
-
QoS0
-
QoS1
-
QoS2
Strongly typed boolean for session presence, for nicer type signatures. (MQTT 3.2.2.2)
pub type SessionPresence {
SessionPresent
SessionNotPresent
}
Constructors
-
SessionPresent
-
SessionNotPresent
A single entry in the SUBSCRIBE payload (MQTT 3.8.3)
pub type SubscribeRequest {
SubscribeRequest(filter: String, qos: QoS)
}
Constructors
-
SubscribeRequest(filter: String, qos: QoS)
The SUBACK payload (MQTT 3.9.3)
pub type SubscribeResult =
Result(QoS, Nil)