struct TLV::Any

Defined in:

tlv/any.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Any #

Parse a single TLV element from IO


[View source]
def self.from_slice(bytes : Bytes) : Any #

Parse from bytes


[View source]
def self.from_tlv(data : Bytes) : Any #

[View source]
def self.new(header : Header, value : Types | Arrays | List | Structure) #

[View source]
def self.new(value : Nil, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

Create TLV::Any from Crystal values


[View source]
def self.new(value : Bool, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

[View source]
def self.new(value : Int8, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

Signed integers - use minimum-size encoding


[View source]
def self.new(value : UInt8, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

Unsigned integers - use minimum-size encoding


[View source]
def self.new(value : Float32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

[View source]
def self.new(value : Float64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

[View source]
def self.new(value : String, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

[View source]
def self.new(value : Bytes, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

[View source]
def self.new(value : Structure, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any #

[View source]
def self.new(value : Int16, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any #

[View source]
def self.new(value : Int32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any #

[View source]
def self.new(value : Int64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any #

[View source]
def self.new(value : UInt16, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any #

[View source]
def self.new(value : UInt32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any #

[View source]
def self.new(value : UInt64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any #

[View source]
def self.new(value : List, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, as_array : Bool = false) : Any #

[View source]

Instance Method Detail

def [](index : Int32) : Any #

Access list/array elements by index


[View source]
def [](tag : TagId) : Any #

Access structure elements by tag


[View source]
def []?(index : Int32) : Any | Nil #

[View source]
def []?(tag : TagId) : Any | Nil #

[View source]
def as_bool : Bool #

[View source]
def as_bytes : Bytes #

[View source]
def as_f32 : Float32 #

[View source]
def as_f64 : Float64 #

[View source]
def as_i16 : Int16 #

[View source]
def as_i32 : Int32 #

[View source]
def as_i64 : Int64 #

[View source]
def as_i8 : Int8 #

Get the raw value cast to specific types (with widening support)


[View source]
def as_list : List #

[View source]
def as_nil : Nil #

[View source]
def as_s : String #

[View source]
def as_structure : Structure #

[View source]
def as_u16 : UInt16 #

[View source]
def as_u32 : UInt32 #

[View source]
def as_u64 : UInt64 #

[View source]
def as_u8 : UInt8 #

[View source]
def container? : Bool #

Check if this is a container


[View source]
def each(& : Any -> ) #

Iterate over list/array entries


[View source]
def each_pair(& : TagId, Any -> ) #

Iterate over structure entries (tag, value pairs)


[View source]
def header : Header #

[View source]
def size : Int32 #

Get size of container


[View source]
def to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Nil #

Write TLV element to IO


[View source]
def to_slice : Bytes #

Serialize to bytes


[View source]
def to_tlv : Bytes #

[View source]
def value : Types | Arrays | List | Structure #

[View source]