class

ASN1::BER::Length

Inherits BinData < Reference < Object

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

Constants

AFTER_DESERIALIZE = [] of Nil

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

BEFORE_SERIALIZE = [] of Nil

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

ENDIAN = ["big"]

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

KLASS_NAME = [ASN1::BER::Length]

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

PARTS = [{type: "bitfield", name: 2, cls: ASN1::BER::Length, onlyif: nil, verify: nil, endian: IO::ByteFormat::BigEndian}, {type: "array", name: long_bytes, cls: UInt8, container: Array(UInt8), onlyif: nil, verify: nil, length: -> do if long && (!indefinite?) if length_indicator > 4 raise(ASN1::InvalidLength.new("invalid ASN.1 BER length: #{length_indicator} length bytes")) end 0 | length_indicator else 0 end end, value: nil}] of Nil

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

REMAINING = [] of Nil

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

Class methods

bit_fields

The length octets of a BER element: short form, long form, or the indefinite marker. The decoded byte count is exposed as #length.

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
indefinite?
Source
length

We can pretty much safely assume no protocol is implementing more than positive Int32 length datagrams

Source
length=(length : Int32)

We can pretty much safely assume no protocol is implementing more than positive Int32 length datagrams

Source
length_indicator
length_indicator=(length_indicator : UInt8)
long
Source
long=(long : UInt8)
long=(value : Bool)
Source
long_bytes
long_bytes=(long_bytes : Array(UInt8))
read(io : IO) : IO

Reads the fields of this instance from io, in declaration order, and returns io. Raises BinData::ParseError (or BinData::VerificationException) on malformed input.

Source
write(io : IO)

Writes the fields of this instance to io in declaration order. Raises BinData::WriteError (or BinData::VerificationException) on failure.

Source