class

TLV::Header

Inherits BinData < Reference < Object

Constants

AFTER_DESERIALIZE = [] of Nil
BEFORE_SERIALIZE = [] of Nil
ENDIAN = ["little"]
KLASS_NAME = [TLV::Header]
PARTS = [{type: "bitfield", name: 0, cls: TLV::Header, onlyif: nil, verify: nil, endian: IO::ByteFormat::LittleEndian}, {type: "group", name: context, cls: Context, onlyif: -> do tag_format == TagType::Context.value end, verify: nil, value: nil}, {type: "group", name: common, cls: Common, onlyif: -> do tag_format == TagType::CommonProfile.value end, verify: nil, value: nil}, {type: "group", name: vendor, cls: Vendor, onlyif: -> do tag_format >= TagType::VendorProfile.value end, verify: nil, value: nil}] of Nil
REMAINING = [] of Nil

Constructors

new(element_type : ElementType, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil)

Creates a header with the given element type and tag

Source

Class methods

bit_fields
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
anonymous?
Source
common

Common Profile - 2 bytes profile + 2 bytes tag

common=(common : TLV::Header::Common)

Common Profile - 2 bytes profile + 2 bytes tag

container?
Source
context
context=(context : TLV::Header::Context)
element_type
Source
element_type=(type : ElementType)
Source
element_type_raw

control byte

element_type_raw=(element_type_raw : UInt8)

control byte

end_of_container?
Source
ids

Returns the tag identifier(s) based on tag type

  • Anonymous: nil
  • Context: UInt8 tag id
  • Common Profile: {profile_id, tag_id}
  • Vendor Profile: {vendor_id, profile_id, tag_id}
Source
tag=(tag : Nil)

Sets the tag based on various formats

Source
tag=(tag : UInt8)
Source
tag=(tag : Tuple(UInt16, UInt16))
Source
tag_format

control byte

tag_format=(tag_format : UInt8)

control byte

tag_type
Source
tag_type=(type : TagType)
Source
vendor

Vendor Profile - 2 bytes vendor + 2 bytes profile + 2 bytes tag

vendor=(vendor : TLV::Header::Vendor)

Vendor Profile - 2 bytes vendor + 2 bytes profile + 2 bytes tag

Nested types