tlv

package
v0.0.0-...-96a7984 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrorTruncated is returned if the binary data does not contain
	// specified number of elements in the TLV's length encoding.
	ErrorTruncated = errors.New("truncated data")

	// ErrorEOF is returned if an unexpected EOF is encountered.
	ErrorEOF = errors.New("unexpected EOF")
)

Functions

This section is empty.

Types

type Symbol

type Symbol struct {
	Name  string
	Child Symtab
}

Symbol specifies a symtab entry.

type Symtab

type Symtab map[Type]Symbol

Symtab specifies mapping from types to their names.

type Tag

type Tag uint64

Tag defines value's type and value type.

func (*Tag) SetType

func (t *Tag) SetType(val Type)

SetType sets the type of the tag.

func (*Tag) SetVType

func (t *Tag) SetVType(val VType)

SetVType sets the type of the tag value.

func (Tag) String

func (t Tag) String() string

func (Tag) Type

func (t Tag) Type() Type

Type returns the type of the tag.

func (Tag) VType

func (t Tag) VType() VType

VType returns the type of the tag value.

type Type

type Type uint32

Type specifies TLV types.

type VType

type VType uint8

VType defines value type.

const (
	VTBool VType = iota
	VTInt
	VTString
	VTData
	VTMap
)

Value types.

func (VType) String

func (vt VType) String() string

type Values

type Values map[Type]interface{}

Values specify a collection of key-value pairs.

func Unmarshal

func Unmarshal(data []byte) (Values, error)

Unmarshal decodes the TLV-encoded data.

func (Values) Dump

func (v Values) Dump(w io.Writer, s Symtab)

Dump prints the value to the specified writer. The Symtab argument specifies type names.

func (Values) Keys

func (v Values) Keys() []Type

Keys returns the keys in sorted order.

func (Values) Marshal

func (v Values) Marshal() ([]byte, error)

Marshal encodes the values into binary TLV-encoding.

Jump to

Keyboard shortcuts

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