encoder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var False = Boolean(0x00)
View Source
var True = Boolean(0xff)

Functions

func EncodeUnit

func EncodeUnit(unit *FilledUnit) (*[]byte, error)

EncodeUnit converts a Unit into a Hermod-encoded byte slice. [2 bytes transmission ID] then for each field value: [2 bytes field ID] [4 bytes content length in bytes (n)] [n bytes content]

func UserEncode

func UserEncode(u UserFacingHermodUnit) (*[]byte, error)

Types

type BigInteger

type BigInteger uint64

type BigSignedInteger

type BigSignedInteger int64

type Boolean

type Boolean uint8

type Field

type Field struct {
	Name     string
	FieldId  uint16
	Type     reflect.Value
	Extended bool // if true, increases maximum value length to 2^64 bytes. otherwise, limit is 2^36 bytes.
	Repeated bool // if true, allows multiple values in the style of a list
}

type FieldValue

type FieldValue struct {
	ParentUnit *FilledUnit
	Value      interface{}
}

type FilledUnit

type FilledUnit struct {
	*Unit
	Values map[Field]FieldValue
}

func DecodeUnit

func DecodeUnit(_rawUnit *[]byte, unit Unit) (*FilledUnit, error)

DecodeUnit attempts (blindly) to decode a Hermod-encoded byte slice into a FilledUnit Errors are returned only for content issues. Structural issues may cause unexpected behaviour, panics, or even infinite loops!

func UserToFilledUnit

func UserToFilledUnit(u UserFacingHermodUnit) (*FilledUnit, error)

type Integer

type Integer uint32

type SignedInteger

type SignedInteger int32

type SmallInteger

type SmallInteger uint16

type SmallSignedInteger

type SmallSignedInteger int16

type String

type String string

type TinyInteger

type TinyInteger uint8

type TinySignedInteger

type TinySignedInteger int8

type Unit

type Unit struct {
	Name           string // a user-readable debug name for this Unit
	TransmissionId uint16 // a unique identifier for this Unit within scope
	Fields         []Field
}

type UserFacingHermodUnit

type UserFacingHermodUnit interface {
	GetDefinition() *Unit
	DecodeAbstract(data *[]byte) (UserFacingHermodUnit, error)
}

func FilledUnitToUser

func FilledUnitToUser(filledUnit *FilledUnit, u UserFacingHermodUnit) (UserFacingHermodUnit, error)

func UserDecode

func UserDecode(u UserFacingHermodUnit, data *[]byte) (UserFacingHermodUnit, error)

Jump to

Keyboard shortcuts

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