Documentation ¶
Index ¶
- Variables
- func Encode(term Term, b *lib.Buffer, options EncodeOptions) (retErr error)
- func NewInvalidTypesError(t reflect.Type, term Term) error
- func ReleaseListAtomCache(l *ListAtomCache)
- func TermIntoStruct(term Term, dest interface{}) (err error)
- func TermProplistIntoStruct(term Term, dest interface{}) (err error)
- func TermToString(t Term) (s string, ok bool)
- type Alias
- type Atom
- type AtomCache
- type CacheItem
- type Charlist
- type DecodeOptions
- type EncodeOptions
- type Export
- type Function
- type InvalidStructKeyError
- type List
- type ListAtomCache
- type ListImproper
- type Map
- type Marshaler
- type Pid
- type Port
- type ProplistElement
- type Ref
- type String
- type StructPopulatorError
- type Term
- type Tuple
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
var ( ErrStringTooLong = fmt.Errorf("Encoding error. String too long. Max allowed length is 65535") ErrAtomTooLong = fmt.Errorf("Encoding error. Atom too long. Max allowed UTF-8 chars is 255") )
Functions ¶
func ReleaseListAtomCache ¶ added in v1.999.200
func ReleaseListAtomCache(l *ListAtomCache)
func TermIntoStruct ¶
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 TermProplistIntoStruct ¶
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
func TermToString ¶
TermToString transforms given term (Atom, []byte, List) to the string
Types ¶
type AtomCache ¶
func NewAtomCache ¶
type Charlist ¶
type Charlist string
Charlist this type is intended to be used to interact with Erlang. Charlist value encodes as a list of int32 numbers in order to support Erlang string with UTF-8 symbols on an Erlang side (Erlang type: [...])
type DecodeOptions ¶
type EncodeOptions ¶
type EncodeOptions struct { LinkAtomCache *AtomCache WriterAtomCache map[Atom]CacheItem EncodingAtomCache *ListAtomCache // FlagV4NC The node accepts a larger amount of data in pids // and references (node container types version 4). // In the pid case full 32-bit ID and Serial fields in NEW_PID_EXT // and in the reference case up to 5 32-bit ID words are now // accepted in NEWER_REFERENCE_EXT. Introduced in OTP 24. FlagV4NC bool // FlagBigCreation The node understands big node creation tags NEW_PID_EXT, // NEWER_REFERENCE_EXT. FlagBigCreation bool }
type InvalidStructKeyError ¶
type InvalidStructKeyError struct {
Term Term
}
func (*InvalidStructKeyError) Error ¶
func (s *InvalidStructKeyError) Error() string
type ListAtomCache ¶ added in v1.999.200
type ListAtomCache struct { L []CacheItem HasLongAtom bool // contains filtered or unexported fields }
func TakeListAtomCache ¶ added in v1.999.200
func TakeListAtomCache() *ListAtomCache
func (*ListAtomCache) Append ¶ added in v1.999.200
func (l *ListAtomCache) Append(a CacheItem)
func (*ListAtomCache) Len ¶ added in v1.999.200
func (l *ListAtomCache) Len() int
func (*ListAtomCache) Reset ¶ added in v1.999.200
func (l *ListAtomCache) Reset()
type ListImproper ¶
type ListImproper []Term
ListImproper as a workaround for the Erlang's improper list [a|b]. Intended to be used to interact with Erlang.
type Marshaler ¶
Marshaler interface implemented by types that can marshal themselves into valid ETF binary Interface implementation must be over the object e.g. (MyObject) UnmarshalETF:
type MyObject struct{} func (m MyObject) MarshalETF() ([]byte, error) { var encoded []byte ... encoding routine ... return encoded, nil }
type ProplistElement ¶
type String ¶
type String string
String this type is intended to be used to interact with Erlang. String value encodes as a binary (Erlang type: <<...>>)
type StructPopulatorError ¶
func (*StructPopulatorError) Error ¶
func (s *StructPopulatorError) Error() string
type Unmarshaler ¶
Unmarshaler interface implemented by types that can unmarshal an ETF binary of themselves. Returns error ErrEmpty for []byte{}. Interface implementation must be over pointer to the object e.g. (*MyObject) UnmarshalETF:
type MyObject struct{} func (m *MyObject) UnmarshalETF(b []byte) error { var err error ... decoding routine ... return err }