Documentation ¶
Overview ¶
Package erltf implements the ETF encoding and decoding format, the implemented version can be located at TermFormatVersion.
Index ¶
Constants ¶
const TermFormatVersion byte = 131
TermFormatVersion is the ETF version this package implements.
Variables ¶
var AlwaysEncodeStringsAsBinary = true
AlwaysEncodeStringsAsBinary is whether to always encode string values using the BinaryExt identifier if they are passed to an Encoder's EncodeAsETF method.
var DefaultBufferSize = 1024 * 1024
DefaultBufferSize is the default size used for a new buffer when creating a new Encoder via NewEncoder. This only works if a nil value is passed or the given byte slice's cap is below this value, in which case it creates a new byte slice and copies the memory.
var DefaultEncodeRecursionDepth = 256
DefaultEncodeRecursionDepth is the default maximum depth an encoder should travel before returning an error.
var ErrEncodeRecursionDepthExceeded = errors.New("github.com/Gophigure/erltf: maximum recursion depth for encoding exceeded")
ErrEncodeRecursionDepthExceeded is returned when an Encoder attempts to encode a value past the maximum recursion depth, it is expected that other implementations of the Encoder interface implement this behavior for consistency.
var ErrListTooLarge = errors.New("github.com/Gophigure/erltf: attempt to encode array, slice or string with a length larger than the uint32 limit")
ErrListTooLarge is returned when attempting to encode an array, slice or string that is too large.
var ErrStringTooLong = errors.New("github.com/Gophigure/erltf: attempt to encode string with size larger than the uint32 limit")
ErrStringTooLong is returned when attempting to encode a string that is too large.
var ErrTooManyPairs = errors.New("github.com/Gophigure/erltf: map has to many key -> value pairs")
ErrTooManyPairs is returned if a map has more pairs than the uint32 limit.
var ErrUnsupportedTypeEncode = errors.New("github.com/Gophigure/erltf: attempt to encode unsupported type (or kind)")
ErrUnsupportedTypeEncode is returned when a value passed to an Encoder's EncodeAsETF function is unsupported.
Functions ¶
This section is empty.
Types ¶
type EncodeETF ¶
EncodeETF can be implemented by custom types to overwrite default behavior when encoding into ETF data.
This is not yet respected as there is no way to currently validate the output.
type Encoder ¶
type Encoder interface { io.Writer io.Reader EncodeAsETF(v any) (n int, err error) EncodeAsBinaryETF(v []byte) (n int, err error) }
Encoder is an interface that can be implemented for either encoding ETF data with a custom type, or to act as a wrapper of an Encoder returned from NewEncoder.
func NewEncoder ¶
NewEncoder returns a new Encoder value ready for use. Passing a nil value or []byte with a cap <= DefaultBufferSize will cause this function to create a new []byte with a cap equal to DefaultBufferSize.
type TermIdentifier ¶
type TermIdentifier byte
TermIdentifier is used for identifying the data type of a payload.
const ( NewFloatExt TermIdentifier = iota + 70 BitBinaryExt AtomCacheRef SmallIntegerExt IntegerExt FloatExt SmallTupleExt LargeTupleExt NilExt StringExt ListExt BinaryExt SmallBigExt LargeBigExt MapExt AtomUTF8Ext SmallAtomUTF8Ext )