class MQTT::V5::Properties

Overview

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

Defined in:

mqtt/v5/property.cr

Constant Summary

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 Method Summary

Instance Method Summary

Class Method Detail

def self.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


[View source]

Instance Method Detail

def __format__ : IO::ByteFormat #

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.


[View source]
def add_pair(id : PropertyId, key : String, value : String) : Nil #

Repeatable, so these append rather than replace


[View source]
def add_variable_byte(id : PropertyId, value : UInt32) : Nil #

[View source]
def all(id : PropertyId) : Array(Property) #

[View source]
def binary(id : PropertyId) : Bytes | Nil #

[View source]
def byte(id : PropertyId) : UInt8 | Nil #

[View source]
def content_length : Int32 #

Length the properties we hold actually occupy


[View source]
def declared_length : Int32 #

Length the wire said the section would be


[View source]
def delete(id : PropertyId) : Nil #

[View source]
def empty? : Bool #

[View source]
def find(id : PropertyId) : Property | Nil #

[View source]
def four_byte(id : PropertyId) : UInt32 | Nil #

[View source]
def len1 : UInt8 #

def len1=(len1 : UInt8) #

def len2 : UInt8 #

def len2=(len2 : UInt8) #

def len3 : UInt8 #

def len3=(len3 : UInt8) #

def len4 : UInt8 #

def len4=(len4 : UInt8) #

def pairs(id : PropertyId) : Array(Tuple(String, String)) #

[View source]
def properties : Array(MQTT::V5::Property) #

def properties=(properties : Array(MQTT::V5::Property)) #

def set_binary(id : PropertyId, value : Slice(UInt8) | Nil) : Nil #

[View source]
def set_byte(id : PropertyId, value : UInt8 | Nil) : Nil #

[View source]
def set_four_byte(id : PropertyId, value : UInt32 | Nil) : Nil #

[View source]
def set_string(id : PropertyId, value : String | Nil) : Nil #

[View source]
def set_two_byte(id : PropertyId, value : UInt16 | Nil) : Nil #

[View source]
def set_variable_byte(id : PropertyId, value : UInt32 | Nil) : Nil #

[View source]
def string(id : PropertyId) : String | Nil #

[View source]
def total_size : Int32 #

Total size on the wire, including the length prefix


[View source]
def two_byte(id : PropertyId) : UInt16 | Nil #

[View source]
def 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


[View source]
def variable_byte(id : PropertyId) : UInt32 | Nil #

[View source]
def variable_bytes(id : PropertyId) : Array(UInt32) #

[View source]