tlv

package module
v0.0.0-...-d18626b Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

tlv

Documentation

Index

Constants

View Source
const (
	// Types and lengths are encoded as vints, but all of the defined types are below 255 so they're just a single byte.
	TypeNull       = uint8(0)  // No-op, no length or value fields
	TypePadding    = uint8(1)  // Value must have specified length but may contain anything
	TypeFragment   = uint8(2)  // Value contains vint id, vint fragment number, vint total fragments, payload
	TypeCompressed = uint8(3)  // Value is a compressed payload. Use compression magic to identify the algorithm used
	TypeBytes      = uint8(10) // Value is just the bytes
	TypeString     = uint8(11) // Value is just the string, no termination symbol
	TypePosInt     = uint8(12) // Value is vint-encoded
	TypeNegInt     = uint8(13) // Value is vint-encoded
)

Variables

This section is empty.

Functions

func EncodeBytes

func EncodeBytes(b []byte) []byte

func EncodeInteger

func EncodeInteger[T constraints.Integer](i T) (z []byte)

func EncodeNull

func EncodeNull() []byte

func EncodePadding

func EncodePadding(p int) []byte

func EncodeString

func EncodeString(s string) []byte

Types

type TLV

type TLV struct {
	Type   uint8
	Length uint64
	Value  []byte
}

func Decode

func Decode(b []byte) (*TLV, int, error)

func DecodeAll

func DecodeAll(b []byte) (z []*TLV)

Jump to

Keyboard shortcuts

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