[−][src]Enum rust_eterm::terms::TermTag

#[repr(u8)]
pub enum TermTag {
    AtomCacheRef,
    SmallInteger,
    Integer,
    Float,
    Port,
    NewPort,
    Pid,
    NewPid,
    SmallTuple,
    LargeTuple,
    Map,
    Nil,
    String,
    List,
    Binary,
    SmallBig,
    LargeBig,
    Reference,
    NewReference,
    NewerReference,
    Fun,
    NewFun,
    Export,
    BitBinary,
    NewFloat,
    AtomUtf8,
    SmallAtomUtf8,
    Atom,
    SmallAtom,
}

Variants

AtomCacheRef

Refers to the atom with AtomCacheReferenceIndex in the distribution header.

Binary representation

1 byte1 byte
82AtomCacheReferenceIndex

String representation

This string is represented just like an atom. The value of this atom is looked up in the distribution header.

SmallInteger

Unsigned 8-bit integer.

Binary representation

1 byte1 byte
97u8

String representation

Represent the value of this 2's complement 8-bit signed integer as either:

The recommendation is to always output like a simple decimal, as it is the simplest and most portable.

Integer

Signed 32-bit integer.

Binary layout

1 byte4 bytes
98i32

String representation

The representations of this 2's complement 32-bit signed integer are:

The recommendation is to always output like a simple decimal, as it is the simplest and most portable.

Float

A finite float (i.e. not inf, -inf or NaN) is stored in string format.

This term is used in minor version 0 of the external format; it has been superseded by NewFloat.

Binary representation

1 byte31 bytes
99Float as string

The format used in sprintf to format the float is %.20e (there are more bytes allocated than necessary).

String representation

The parsable values should be a decimal integer with either an exponent or a trailing dot with 1 or more numbers behind it. An optional base can also be specified in front of it, separating the value and base with an octothorpe (#).

The recommendation is to output with the format being %.20e as it is guaranteed not to lose precision.

Port

Same as NewPort except the Creation field is only one byte and only two bits are significant, the rest are to be 0.

Binary representation

1 byteN bytes4 bytes1 byte
102NodeIDCreation

String representation

There is not actually a good way to represent a port as a string because the Node value may not be known. A representation of #Port<0.{id}.{creation}> can be used as a means to visualize the value of a port regardless.

NewPort

Encodes a port identifier (obtained from erlang:open_port/2).

Introduced in OTP 19, but only to be decoded and echoed back. Not encoded for local ports. Planned to supersede PORT_EXT in OTP 23 when DFLAG_BIG_CREATON becomes mandatory.

Binary representation

1 byteN bytes4 bytes4 bytes
89NodeIDCreation

String representation

There is not actually a good way to represent a port as a string because the Node value may not be known. A representation of #Port<0.{id}.{creation}> can be used as a means to visualize the value of a port regardless.

Pid

Same as NewPid except the Creation field is only one byte and only two bits are significant, the rest are to be 0.

Binary representation

1 byteN bytes4 bytes4 bytes1 byte
103NodeIDSerialCreation

String representation

There is not actually a good way to represent a pid as a string because the Node value may not be known. A representation of <0.{id}.{creation}> can be used as a means to visualize the value of a pid regardless.

NewPid

Encodes an Erlang process identifier object.

Introduced in OTP 19, but only to be decoded and echoed back. Not encoded for local processes. Planned to supersede Pid in OTP 23 when DFLAG_BIG_CREATON becomes mandatory.

Binary representation

1 byteN bytes4 bytes4 bytes4 bytes
88NodeIDSerialCreation

String representation

There is not actually a good way to represent a pid as a string because the Node value may not be known. A representation of <0.{id}.{creation}> can be used as a means to visualize the value of a pid regardless.

SmallTuple

Encodes a tuple.

Binary representation

1 byte1 byteN bytes
104ArityElements

String representation

The string representation is simply a comma-separated list of stringified terms completely wrapped with curly braces.

LargeTuple

Same as SmallTuple except that Arity is an unsigned 4 byte integer.

Binary representation

1 byte4 bytesN bytes
105ArityElements

String representation

The string representation is simply a comma-separated list of stringified terms completely wrapped with curly braces.

Map

Encodes a map.

Binary representation

1 byte4 bytesN bytes
116ArityPairs

String representation

A map is represented like this:

#{ key0 => value0 (, keyN => valueN )* }

Nil

The representation for an empty list, that is, the Erlang syntax [].

Binary representation

1 byte
106

String representation

[].

String

String does not have a corresponding Erlang representation, but is an optimization for sending lists of bytes (integer in the range 0-255) more efficiently over the distribution.

As field Length is an unsigned 2 byte integer (big-endian), implementations must ensure that lists longer than 65535 elements are encoded as List.

Binary representation

1 byte2 bytesLength bytes
107LengthCharacters

The characters are UTF-8 encoded characters. There are a maximum of 65535 bytes, however many characters that turns out to be. It is not a maximum of 65535 characters!

String representation

Place the string between double quotes, and apply the following escape sequences:

Actual characterEscape sequence
backspace\b
delete\d
escape\e
form feed\f
newline\n
carriage return\r
tab\t
vertical tab\v
double qoute (")\"
List

The representation for a non-empty list.

Binary representation

1 byte4 bytesN bytesM bytes
108LengthElementsTail

String representation

Place a comma-separated list of stringified terms between block-quotes.

Binary

Binaries are byte-arrays. They are represented as bitstrings or binaries in the Erlang language.

Binary representation

1 byte4 bytesLen bytes
109LenData

String representation

The output format is simply to convert each byte to a decimal number and print them as a comma-separated list between a pair of double angle brackets (<<, >>).

For reading, the values should be any of:

SmallBig

Integer representation of an integer N where -2^256 < N < 2^256.

Binary representation

1 byte1 byte1 byteLen bytes
110LenSignd0..d(Len - 1)

Bignums are stored in unary form with a Sign byte, that is, 0 if the bignum is positive and 1 if it is negative. The digits are stored with the least significant byte stored first. To calculate the integer, the following formula can be used:

B = 256
(d0*B^0 + d1*B^1 + d2*B^2 + ... d(N-1)*B^(n-1))

String representation

The representations of this 2's complement 32-bit signed integer are:

The recommendation is to always output like a simple decimal, as it is the simplest and most portable.

LargeBig

Integer representation of an integer N where -2^(2^32) < N < 2^(2^32).

Binary representation

1 byte4 bytes1 byteLen bytes
111LenSignd0..d(Len - 1)

Bignums are stored in unary form with a Sign byte, that is, 0 if the bignum is positive and 1 if it is negative. The digits are stored with the least significant byte stored first. To calculate the integer, the following formula can be used:

B = 256
(d0*B^0 + d1*B^1 + d2*B^2 + ... d(N-1)*B^(n-1))

String representation

The representations of this 2's complement 32-bit signed integer are:

The recommendation is to always output like a simple decimal, as it is the simplest and most portable.

Reference

Deprecated method for encoding a reference term.

Binary representation

1 byteN bytes4 bytes1 byte
101NodeIDCreation
NewReference

Deprecated method for encoding a reference term.

Binary representation

1 byte2 bytesN bytes1 byteLen * 4 bytes
101LenNodeCreationID
NewerReference

Encodes a reference term.

Binary representation

1 byte2 bytesN bytes4 bytesLen * 4 bytes
90LenNodeCreationID
Fun

Old encoding of internal functions: fun F/A and fun(Arg1,..) -> ... end.

Binary representation

1 byte4 bytesN bytesN' bytesN'' bytesN''' bytesN'''' bytes
117NumFreePidModuleIndexUniqFree vars...
NewFun

Encoding of internal functions: fun F/A and fun(Arg1,..) -> ... end.

Binary representation

1 byte4 bytes1 byte16 bytes4 bytes4 bytesN bytesN' bytesN'' bytesN''' bytesN'''' bytes
112SizeArityUniqIndexNumFreeModuleOldIndexOldUniqPidFree vars...
Export

Encodes functions of the shape fun M:F/A.

Binary representation

1 byteN bytesN' bytesN'' bytes
113ModuleFunctionArity
BitBinary

This term represents a bitstring whose length in bits does not have to be a multiple of 8.

Binary representation

1 byte4 bytes1 byteLen bytes
77LenBitsData
NewFloat

This term represents a float

Binary representation

1 byte8 bytes
70Float
AtomUtf8

This term represents an atom.

Binary representation

1 byte2 bytesLen bytes
118LenAtomName
SmallAtomUtf8

This term represents an atom that takes up at most 255 bytes (which may be less than 255 characters as UTF-8 can have multi-byte characters).

Binary representation

1 byte1 byteLen bytes
118LenAtomName
Atom

This represents a LATIN-1 atom, but should not be encoded anymore.

Binary representation

1 byte2 bytesLen bytes
118LenAtomName
SmallAtom

This represents a LATIN-1 atom, but should not be encoded anymore.

Binary representation

1 bytebyteLen bytes
118LenAtomName

Trait Implementations

impl TryFrom<u8> for TermTag[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for TermTag

impl Send for TermTag

impl Sync for TermTag

impl Unpin for TermTag

impl UnwindSafe for TermTag

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.