ExIcaoVds.Length (ex_icao_vds v0.3.2)

Copy Markdown

Variable-length encoding used in VDS TLV fields.

Encoding rules:

  • 0–127 → 1 byte <<n>>
  • 128–255 → 2 bytes <<0x81, n>>
  • 256–65535 → 3 bytes <<0x82, high, low>>
  • 65536–16777215 → 4 bytes <<0x83, b2, b1, b0>>

Summary

Functions

Decode a length prefix from the start of bytes. Returns {:ok, length, rest} where rest is the bytes after the prefix.

Encode n as a length prefix binary.

Functions

decode(arg)

@spec decode(binary()) :: {:ok, non_neg_integer(), binary()} | {:error, term()}

Decode a length prefix from the start of bytes. Returns {:ok, length, rest} where rest is the bytes after the prefix.

encode(n)

@spec encode(non_neg_integer()) :: {:ok, binary()} | {:error, term()}

Encode n as a length prefix binary.