tlv

package
v0.0.0-...-3192b2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Anonymous             tagControl = 0x00
	ContextSpecific       tagControl = 0x20
	CommonProfile2Bytes   tagControl = 0x40
	CommonProfile4Bytes   tagControl = 0x60
	ImplicitProfile2Bytes tagControl = 0x80
	ImplicitProfile4Bytes tagControl = 0xA0
	FullyQualified6Bytes  tagControl = 0xC0
	FullyQualified8Bytes  tagControl = 0xE0
)

Variables

View Source
var ByteLenError error = errors.New("tlv data length err")
View Source
var EndOfTLVError error = errors.New("end of tlv")

Functions

func EstimateStructOverhead

func EstimateStructOverhead(firstFieldSize int, args ...int) int

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

A Decoder reads and decodes tlv values from an input stream.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new decoder that reads from r. The decoder introduces its own buffering and may readData data from r beyond the JSON values requested.

func (*Decoder) EnterContainer

func (dec *Decoder) EnterContainer() (Type, error)

func (*Decoder) ExitContainer

func (dec *Decoder) ExitContainer(outerContainerType Type) error

func (*Decoder) Get

func (dec *Decoder) Get(out any) error

func (*Decoder) GetBoolean

func (dec *Decoder) GetBoolean() (bool, error)

func (*Decoder) GetBytes

func (dec *Decoder) GetBytes() (data []byte, err error)

func (*Decoder) GetF32

func (dec *Decoder) GetF32() (f32 float32, err error)

func (*Decoder) GetF64

func (dec *Decoder) GetF64() (f64 float64, err error)

func (*Decoder) GetI16

func (dec *Decoder) GetI16() (i16 int16, err error)

func (*Decoder) GetI32

func (dec *Decoder) GetI32() (i32 int32, err error)

func (*Decoder) GetI8

func (dec *Decoder) GetI8() (i8 int8, err error)

func (*Decoder) GetInt

func (dec *Decoder) GetInt() (int64, error)

func (*Decoder) GetTag

func (dec *Decoder) GetTag() Tag

func (*Decoder) GetU16

func (dec *Decoder) GetU16() (uint16, error)

func (*Decoder) GetU32

func (dec *Decoder) GetU32() (uint32, error)

func (*Decoder) GetU8

func (dec *Decoder) GetU8() (uint8, error)

func (*Decoder) GetUint

func (dec *Decoder) GetUint() (uint64, error)

func (*Decoder) Next

func (dec *Decoder) Next() error

func (*Decoder) NextTag

func (dec *Decoder) NextTag(tag Tag) error

func (*Decoder) NextType

func (dec *Decoder) NextType(expectedType Type, expectedTag Tag) error

func (*Decoder) NextValue

func (dec *Decoder) NextValue(tag Tag, out any) error

func (*Decoder) TagError

func (dec *Decoder) TagError(val any) error

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) EndContainer

func (enc *Encoder) EndContainer(outerContainerType Type) error

func (*Encoder) Put

func (enc *Encoder) Put(tag Tag, v any) error

func (*Encoder) PutBoolean

func (enc *Encoder) PutBoolean(tag Tag, b bool) error

func (*Encoder) PutBytes

func (enc *Encoder) PutBytes(tag Tag, data []byte) error

func (*Encoder) PutF32

func (enc *Encoder) PutF32(tag Tag, f32 float32) error

func (*Encoder) PutF64

func (enc *Encoder) PutF64(tag Tag, f64 float64) error

func (*Encoder) PutI16

func (enc *Encoder) PutI16(tag Tag, val int16) error

func (*Encoder) PutI32

func (enc *Encoder) PutI32(tag Tag, val int32) error

func (*Encoder) PutI64

func (enc *Encoder) PutI64(tag Tag, val int64) error

func (*Encoder) PutI8

func (enc *Encoder) PutI8(tag Tag, val int8) error

func (*Encoder) PutU16

func (enc *Encoder) PutU16(tag Tag, val uint16) error

func (*Encoder) PutU32

func (enc *Encoder) PutU32(tag Tag, val uint32) error

func (*Encoder) PutU64

func (enc *Encoder) PutU64(tag Tag, val uint64) error

func (*Encoder) PutU8

func (enc *Encoder) PutU8(tag Tag, val uint8) error

func (*Encoder) PutUTFString

func (enc *Encoder) PutUTFString(tag Tag, str string) error

func (*Encoder) StartContainer

func (enc *Encoder) StartContainer(tag Tag, tlvType Type) (outerContainerType Type, err error)

func (*Encoder) Status

func (enc *Encoder) Status() error

func (*Encoder) WriteElementWithData

func (enc *Encoder) WriteElementWithData(tlvType Type, tag Tag, data []byte) error

type Tag

type Tag uint64

func AnonymousTag

func AnonymousTag() Tag

func ContextTag

func ContextTag(tagNum uint8) Tag

func (Tag) Number

func (t Tag) Number() uint32

type Type

type Type int8
const (
	TypeNotSpecified        Type = -1
	TypeUnknownContainer    Type = -2
	TypeSignedInteger       Type = 0x00 //• Signed integers
	TypeUnsignedInteger     Type = 0x04 //• Unsigned integers
	TypeUTF8String          Type = 0x0C //• UTF-8 Strings
	TypeByteString          Type = 0x10 //• Octet Strings
	TypeFloatingPointNumber Type = 0x0A //• Single or double-precision floating point numbers (following IEEE 754-2019) • Booleans
	TypeBoolean             Type = 0x08 //• Booleans
	TypeNull                Type = 0x14 //• Nulls
	TypeStructure           Type = 0x15
	TypeArray               Type = 0x16
	TypeList                Type = 0x17
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL