Skip to content

EMessage

[Source]

An encoded Erlang message: the bytes of one term in the external format.

EMessage.begin() starts an empty message to encode into, encode(term) writes a whole term into it, and the decode_* functions read terms out at a position. For the usual "bytes in, term out" direction see ErlangTermDecoder.

class ref EMessage

Constructors

begin

[Source]

new ref begin()
: EMessage ref^

Returns


from_cpointer

[Source]

Takes ownership of a message received from the C layer.

new ref from_cpointer(
  message': Pointer[None val] ref)
: EMessage ref^

Parameters

Returns


Public fields

let beginning: I32 val

[Source]


Public Functions

valid

[Source]

fun ref valid()
: Bool val

Returns


length

[Source]

fun ref length()
: USize val

Returns


write_position

[Source]

Where the next term would start.

fun ref write_position()
: I32 val

Returns


truncate

[Source]

Forgets everything written after position.

fun ref truncate(
  position: I32 val)
: Bool val

Parameters

  • position: I32 val

Returns


cpointer

[Source]

fun ref cpointer()
: Pointer[None val] ref

Returns


type_at

[Source]

The type tag and payload size of the term at position.

fun ref type_at(
  position: I32 val)
: (I32 val , I32 val)

Parameters

  • position: I32 val

Returns


skip_term

[Source]

The position just past the term at position, -1 for an invalid term.

fun ref skip_term(
  position: I32 val)
: I32 val

Parameters

  • position: I32 val

Returns


copy_bytes

[Source]

The encoded bytes of a term, which is how unmodelled terms are kept.

fun ref copy_bytes(
  from: I32 val,
  to: I32 val)
: (String val | None val)

Parameters

Returns


append_raw

[Source]

Appends bytes that are already in the external format.

fun ref append_raw(
  encoded: String val)
: I32 val

Parameters

Returns


decode_atom

[Source]

fun ref decode_atom(
  position: I32 val)
: ((String val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_int

[Source]

fun ref decode_int(
  position: I32 val)
: ((I64 val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_double

[Source]

fun ref decode_double(
  position: I32 val)
: ((F64 val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_binary

[Source]

fun ref decode_binary(
  position: I32 val)
: ((String val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_bitstring

[Source]

fun ref decode_bitstring(
  position: I32 val)
: ((ErlangBitstring val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_string

[Source]

fun ref decode_string(
  position: I32 val)
: ((String val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_list_header

[Source]

fun ref decode_list_header(
  position: I32 val)
: (I32 val , I32 val)

Parameters

  • position: I32 val

Returns


decode_tuple_header

[Source]

fun ref decode_tuple_header(
  position: I32 val)
: (I32 val , I32 val)

Parameters

  • position: I32 val

Returns


decode_map_header

[Source]

fun ref decode_map_header(
  position: I32 val)
: (I32 val , I32 val)

Parameters

  • position: I32 val

Returns


decode_pid

[Source]

fun ref decode_pid(
  position: I32 val)
: ((ErlangPid val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_port

[Source]

fun ref decode_port(
  position: I32 val)
: ((ErlangPort val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


decode_reference

[Source]

fun ref decode_reference(
  position: I32 val)
: ((ErlangReference val | None val) , I32 val)

Parameters

  • position: I32 val

Returns


encode

[Source]

Writes a whole term into the message.

A term that cannot be written leaves the message as it was, so a caller that handles the error does not send a truncated term.

fun ref encode(
  term: ErlangTerm)
: None val ?

Parameters

Returns


encode_atom

[Source]

fun ref encode_atom(
  name: String val)
: I32 val

Parameters

Returns


encode_int

[Source]

fun ref encode_int(
  value: I64 val)
: I32 val

Parameters

  • value: I64 val

Returns


encode_double

[Source]

fun ref encode_double(
  value: F64 val)
: I32 val

Parameters

  • value: F64 val

Returns


encode_binary

[Source]

fun ref encode_binary(
  value: String val)
: I32 val

Parameters

Returns


encode_bitstring

[Source]

fun ref encode_bitstring(
  value: String val,
  used_bits_in_last_byte: U8 val)
: I32 val

Parameters

  • value: String val
  • used_bits_in_last_byte: U8 val

Returns


encode_string

[Source]

fun ref encode_string(
  value: String val)
: I32 val

Parameters

Returns


encode_list_header

[Source]

fun ref encode_list_header(
  arity: USize val)
: I32 val

Parameters

Returns


encode_empty_list

[Source]

fun ref encode_empty_list()
: I32 val

Returns


encode_tuple_header

[Source]

fun ref encode_tuple_header(
  arity: USize val)
: I32 val

Parameters

Returns


encode_map_header

[Source]

fun ref encode_map_header(
  arity: USize val)
: I32 val

Parameters

Returns


encode_pid

[Source]

fun ref encode_pid(
  node: String val,
  num: U32 val,
  serial: U32 val,
  creation: U32 val)
: I32 val

Parameters

Returns


encode_port

[Source]

fun ref encode_port(
  node: String val,
  id: U64 val,
  creation: U32 val)
: I32 val

Parameters

Returns


encode_reference

[Source]

fun ref encode_reference(
  node: String val,
  ids: Array[U32 val] val,
  creation: U32 val)
: I32 val

Parameters

Returns


dispose

[Source]

Frees the message now instead of waiting for the collector.

fun ref dispose()
: None val

Returns