etf

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStringTooLong = fmt.Errorf("Encoding error. String too long")
)

Functions

func Encode

func Encode(term Term, b *lib.Buffer,
	linkAtomCache *AtomCache,
	writerAtomCache map[Atom]CacheItem,
	encodingAtomCache *ListAtomCache) (retErr error)

func NewInvalidTypesError

func NewInvalidTypesError(t reflect.Type, term Term) error

func ReleaseListAtomCache

func ReleaseListAtomCache(l *ListAtomCache)

func StringTerm

func StringTerm(t Term) (s string, ok bool)

func TermIntoStruct

func TermIntoStruct(term Term, dest interface{}) (err error)

TermIntoStruct transforms 'term' (etf.Term, etf.List, etf.Tuple, etf.Map) into the given 'dest' (could be a struct, map, slice or array). Its a pretty expencive operation in terms of CPU usage so you shouldn't use it on highload parts of your code. Use manual type casting instead.

func TermMapIntoStruct added in v1.2.0

func TermMapIntoStruct(term Term, dest interface{}) (err error)

TermMapIntoSturct transforms etf.Map into the given 'dest'. There are limitations to use this helper. A key of the given etf.Map must be a string or etf.Atom. 'dest' must be a structure with specified tag 'etf' and the name of a key for every single field.

func TermProplistIntoStruct added in v1.2.0

func TermProplistIntoStruct(term Term, dest interface{}) (err error)

ProplistIntoStruct transorms given term into the provided struct 'dest'. Proplist is the list of Tuple values with two items { Name , Value }, where Name can be string or Atom and Value must be the same type as it has the field of 'dest' struct with the equivalent name. Its also accepts []ProplistElement as a 'term' value

Types

type Atom

type Atom string

type AtomCache

type AtomCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAtomCache

func NewAtomCache(ctx context.Context) *AtomCache

func (*AtomCache) Append

func (a *AtomCache) Append(atom Atom)

func (*AtomCache) GetLastID

func (a *AtomCache) GetLastID() int16

func (*AtomCache) List

func (a *AtomCache) List() [maxCacheItems]Atom

func (*AtomCache) ListSince

func (a *AtomCache) ListSince(id int16) []Atom

type CacheItem

type CacheItem struct {
	ID      int16
	Encoded bool
	Name    Atom
}

type Export

type Export struct {
	Module   Atom
	Function Atom
	Arity    int
}

type Function

type Function struct {
	Arity  byte
	Unique [16]byte
	Index  uint32
	//	Free      uint32
	Module    Atom
	OldIndex  uint32
	OldUnique uint32
	Pid       Pid
	FreeVars  []Term
}

type InvalidStructKeyError

type InvalidStructKeyError struct {
	Term Term
}

func (*InvalidStructKeyError) Error

func (s *InvalidStructKeyError) Error() string

type List

type List []Term

func (List) Element

func (l List) Element(i int) Term

type ListAtomCache

type ListAtomCache struct {
	L []CacheItem

	HasLongAtom bool
	// contains filtered or unexported fields
}

func TakeListAtomCache

func TakeListAtomCache() *ListAtomCache

func (*ListAtomCache) Append

func (l *ListAtomCache) Append(a CacheItem)

func (*ListAtomCache) Len

func (l *ListAtomCache) Len() int

func (*ListAtomCache) Reset

func (l *ListAtomCache) Reset()

type Map

type Map map[Term]Term

func (Map) Element

func (m Map) Element(k Term) Term

type Pid

type Pid struct {
	Node     Atom
	ID       uint32
	Serial   uint32
	Creation byte
}

func (Pid) Str

func (p Pid) Str() string

type Port

type Port struct {
	Node     Atom
	ID       uint32
	Creation byte
}

type ProplistElement added in v1.2.0

type ProplistElement struct {
	Name  Atom
	Value Term
}

type Ref

type Ref struct {
	Node     Atom
	Creation byte
	ID       []uint32
}

func (Ref) String added in v1.2.0

func (ref Ref) String() string

type StructPopulatorError

type StructPopulatorError struct {
	Type reflect.Type
	Term Term
}

func (*StructPopulatorError) Error

func (s *StructPopulatorError) Error() string

type Term

type Term interface{}

func Decode

func Decode(packet []byte, cache []Atom) (retTerm Term, retByte []byte, retErr error)

type Tuple

type Tuple []Term

func (Tuple) Element

func (t Tuple) Element(i int) Term

Jump to

Keyboard shortcuts

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