libero/wire

ETF (Erlang Term Format) wire codec for Libero RPC.

Encoding walks any Gleam value through erlang:term_to_binary/1, which preserves the full Erlang type structure — atoms, tuples, maps, lists — natively. Decoding uses erlang:binary_to_term/1 to reconstruct the original terms. No manual walk or rebuild is needed because ETF is the BEAM’s native serialization format.

Wire shape:

Types

pub type DecodeError {
  DecodeError(message: String)
}

Constructors

  • DecodeError(message: String)

Values

pub fn decode_call(
  data: BitArray,
) -> Result(#(String, List(dynamic.Dynamic)), DecodeError)

Parse a {<<"fn_name">>, [arg1, arg2, ...]} tuple from an ETF binary. Returns the function name and args list. Since binary_to_term returns real Erlang terms, no rebuild step is needed — atoms are atoms, tuples are tuples, maps are maps.

pub fn encode(value: a) -> BitArray

Encode any Gleam value to an ETF binary.

Search Document