class

MQTT::V5::Properties

Inherits BinData / Reference / Object

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

Constants

AFTER_DESERIALIZE = [] of Nil

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

BEFORE_SERIALIZE = [] of Nil

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

ENDIAN = ["big"]

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

KLASS_NAME = [MQTT::V5::Properties]

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

PARTS = [{type: "basic", name: len1, cls: UInt8, onlyif: nil, verify: nil, value: -> do encoded_length[0] end, endian: nil}, {type: "basic", name: len2, cls: UInt8, onlyif: -> do (len1 & 128) > 0 end, verify: nil, value: -> do encoded_length[1] end, endian: nil}, {type: "basic", name: len3, cls: UInt8, onlyif: -> do (len2 & 128) > 0 end, verify: nil, value: -> do encoded_length[2] end, endian: nil}, {type: "basic", name: len4, cls: UInt8, onlyif: -> do (len3 & 128) > 0 end, verify: nil, value: -> do encoded_length[3] end, endian: nil}, {type: "variable_array", name: properties, cls: MQTT::V5::Property, container: Array(MQTT::V5::Property), onlyif: nil, verify: nil, read_next: -> do (properties.sum(0, &.bytesize)) < declared_length end, value: nil}] of Nil

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

REMAINING = [] of Nil

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

Class methods

bit_fields

The property section carried by nearly every 5.0 packet: a variable byte integer length, then properties until that many bytes are consumed

Source

Instance methods

__format__

A group or bit_field captures the endianness at its declaration point, so declaring endian after one would silently leave it system-endian. Fail loudly.

Source
add_pair(id : PropertyId, key : String, value : String) : Nil

Repeatable, so these append rather than replace

Source
add_variable_byte(id : PropertyId, value : UInt32) : Nil
Source
all(id : PropertyId) : Array(Property)
Source
binary(id : PropertyId) : Bytes | Nil
Source
byte(id : PropertyId) : UInt8 | Nil
Source
content_length

Length the properties we hold actually occupy

Source
declared_length

Length the wire said the section would be

Source
delete(id : PropertyId) : Nil
Source
empty?
Source
find(id : PropertyId) : Property | Nil
Source
four_byte(id : PropertyId) : UInt32 | Nil
Source
len1
len1=(len1 : UInt8)
len2
len2=(len2 : UInt8)
len3
len3=(len3 : UInt8)
len4
len4=(len4 : UInt8)
pairs(id : PropertyId) : Array(Tuple(String, String))
Source
properties
properties=(properties : Array(MQTT::V5::Property))
set_binary(id : PropertyId, value : Slice(UInt8) | Nil) : Nil
Source
set_byte(id : PropertyId, value : UInt8 | Nil) : Nil
Source
set_four_byte(id : PropertyId, value : UInt32 | Nil) : Nil
Source
set_string(id : PropertyId, value : String | Nil) : Nil
Source
set_two_byte(id : PropertyId, value : UInt16 | Nil) : Nil
Source
set_variable_byte(id : PropertyId, value : UInt32 | Nil) : Nil
Source
string(id : PropertyId) : String | Nil
Source
total_size

Total size on the wire, including the length prefix

Source
two_byte(id : PropertyId) : UInt16 | Nil
Source
validate!(allowed : Enumerable(PropertyId), packet : String) : self

Checks the section against the properties legal for a given packet. A property that may only appear once, appearing twice, is a protocol error rather than something to silently take the last of

Source
variable_byte(id : PropertyId) : UInt32 | Nil
Source
variable_bytes(id : PropertyId) : Array(UInt32)
Source