Documentation ¶
Index ¶
- Variables
- func Encode(term Term, b *lib.Buffer, options EncodeOptions) (retErr error)
- func NewInvalidTypesError(t reflect.Type, term Term) error
- func ReleaseEncodingAtomCache(l *EncodingAtomCache)
- func TermIntoStruct(term Term, dest interface{}) (err error)
- func TermProplistIntoStruct(term Term, dest interface{}) (err error)
- func TermToString(t Term) (s string, ok bool)
- func UnregisterType(name Atom) error
- type Alias
- type Atom
- type AtomCache
- type AtomCacheIn
- type AtomCacheOut
- type AtomMapping
- type CacheItem
- type Charlist
- type DecodeOptions
- type EncodeOptions
- type EncodingAtomCache
- type Export
- type Function
- type InvalidStructKeyError
- type List
- type ListImproper
- type Map
- type Marshaler
- type Pid
- type Port
- type ProplistElement
- type Ref
- type RegisterTypeOptions
- 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 ReleaseEncodingAtomCache ¶
func ReleaseEncodingAtomCache(l *EncodingAtomCache)
ReleaseEncodingAtomCache
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 ¶
TermProplistIntoStruct 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
func UnregisterType ¶
UnregisterType unregisters type with a given name.
Types ¶
type Atom ¶
type Atom string
Atom
func RegisterType ¶
func RegisterType(t interface{}, options RegisterTypeOptions) (Atom, error)
RegisterType registers new type with the given options. It returns a Name of the registered type, which can be used in the UnregisterType function for unregistering this type. Supported types: struct, slice, array, map. Returns an error if this type can not be registered.
type AtomCache ¶
type AtomCache struct { In *AtomCacheIn Out *AtomCacheOut }
type AtomCacheIn ¶
type AtomCacheIn struct {
Atoms [maxCacheItems]*Atom
}
type AtomCacheOut ¶
AtomCache
type AtomMapping ¶
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 DecodeOptions struct { AtomMapping *AtomMapping FlagBigPidRef bool }
DecodeOptions
type EncodeOptions ¶
type EncodeOptions struct { AtomCache *AtomCacheOut SenderAtomCache map[Atom]CacheItem EncodingAtomCache *EncodingAtomCache AtomMapping *AtomMapping // FlagBigPidRef 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. FlagBigPidRef bool // FlagBigCreation The node understands big node creation tags NEW_PID_EXT, // NEWER_REFERENCE_EXT. FlagBigCreation bool NodeName string PeerName string }
EncodeOptions
type EncodingAtomCache ¶
type EncodingAtomCache struct { L []CacheItem HasLongAtom bool // contains filtered or unexported fields }
EncodingAtomCache
type Function ¶
type Function struct { Arity byte Unique [16]byte Index uint32 // Free uint32 Module Atom OldIndex uint32 OldUnique uint32 Pid Pid FreeVars []Term }
Function
type InvalidStructKeyError ¶
type InvalidStructKeyError struct {
Term Term
}
func (*InvalidStructKeyError) Error ¶
func (s *InvalidStructKeyError) Error() string
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 RegisterTypeOptions ¶
RegisterTypeOptins defines custom name for the registering type. Leaving the Name option empty makes the name automatically generated. Strict option defines whether the decoding process causes panic if the decoding value doesn't fit the destination object.
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 }