This module contains functions for encoding Erlang terms into a sequence of bytes, and for decoding Erlang terms from a sequence of bytes.
This function compares two encoded terms.
The function returns 0 if the terms are equal, -1 if term1 is less than term2, or 1 if term2 is less than term1.
These functions returns the number of bytes written to buffer if successful, otherwise returns 0.
Note that no bounds checking is done on the buffer. It is
the caller's responsibility to make sure that the buffer is
large enough to hold the encoded terms. You can either use a
static buffer that is large enough to hold the terms you
expect to need in your program, or use
The following can help you estimate the buffer
requirements for a term. Note that this information is
implementation specific, and may change in future versions.
If you are unsure, use
Erlang terms are encoded with a 1 byte tag that identifies the type of object, a 2- or 4-byte length field, and then the data itself. Specifically:
The total space required will be the result calculated from the information above, plus 1 additional byte for a version identifier.
This function returns the number of elements in an encoded term.
This function identifies and returns the type of Erlang term encoded
in a buffer. It will skip a trailing magic identifier.
Returns
ERL_INTEGER
ERL_ATOM
ERL_PID
ERL_PORT
ERL_REF
ERL_EMPTY_LIST
ERL_LIST
ERL_TUPLE
ERL_FLOAT
ERL_BINARY
ERL_FUNCTION
This function is used for stepping over one or more encoded terms in a buffer, in order to directly access a later term.
The function returns a pointer to a sub-term that can be
used in a subsequent call to
This function determines the buffer space that would be
needed by
The size in bytes is returned.