struct
TLV::Any
- TLV::Any
- Struct
- Value
- Object
Defined in:
tlv/any.crConstructors
-
.from_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Any
Parse a single TLV element from IO
-
.from_slice(bytes : Bytes) : Any
Parse from bytes
- .from_tlv(data : Bytes) : Any
- .new(header : Header, value : Types | Arrays | List | Structure)
-
.new(value : Nil, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
Create TLV::Any from Crystal values
- .new(value : Bool, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
-
.new(value : Int8, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
Signed integers - use minimum-size encoding
-
.new(value : UInt8, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
Unsigned integers - use minimum-size encoding
- .new(value : Float32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
- .new(value : Float64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
- .new(value : String, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
- .new(value : Bytes, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
- .new(value : Structure, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
- .new(value : Int16, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
- .new(value : Int32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
- .new(value : Int64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
- .new(value : UInt16, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
- .new(value : UInt32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
- .new(value : UInt64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
- .new(value : List, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, as_array : Bool = false) : Any
Instance Method Summary
-
#[](index : Int32) : Any
Access list/array elements by index
-
#[](tag : TagId) : Any
Access structure elements by tag
- #[]?(index : Int32) : Any | Nil
- #[]?(tag : TagId) : Any | Nil
- #as_bool : Bool
- #as_bytes : Bytes
- #as_f32 : Float32
- #as_f64 : Float64
- #as_i16 : Int16
- #as_i32 : Int32
- #as_i64 : Int64
-
#as_i8 : Int8
Get the raw value cast to specific types (with widening support)
- #as_list : List
- #as_nil : Nil
- #as_s : String
- #as_structure : Structure
- #as_u16 : UInt16
- #as_u32 : UInt32
- #as_u64 : UInt64
- #as_u8 : UInt8
-
#container? : Bool
Check if this is a container
-
#each(& : Any -> )
Iterate over list/array entries
-
#each_pair(& : TagId, Any -> )
Iterate over structure entries (tag, value pairs)
- #header : Header
-
#size : Int32
Get size of container
-
#to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Nil
Write TLV element to IO
-
#to_slice : Bytes
Serialize to bytes
- #to_tlv : Bytes
- #value : Types | Arrays | List | Structure
Constructor Detail
Parse a single TLV element from IO
def self.new(value : Nil, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
Create TLV::Any from Crystal values
def self.new(value : Bool, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
def self.new(value : Int8, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
Signed integers - use minimum-size encoding
def self.new(value : UInt8, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
Unsigned integers - use minimum-size encoding
def self.new(value : Float32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
def self.new(value : Float64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
def self.new(value : String, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
def self.new(value : Bytes, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
def self.new(value : Structure, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil) : Any
#
def self.new(value : Int16, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
#
def self.new(value : Int32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
#
def self.new(value : Int64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
#
def self.new(value : UInt16, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
#
def self.new(value : UInt32, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
#
def self.new(value : UInt64, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, fixed_size : Bool = false) : Any
#
def self.new(value : List, tag : Nil | UInt8 | Tuple(UInt16, UInt16) | Tuple(UInt16, UInt16, UInt16) = nil, *, as_array : Bool = false) : Any
#
Instance Method Detail
Write TLV element to IO