AirPlay.V2.TLV (AirPlay v0.3.1)

Copy Markdown View Source

AirPlay 2 TLV8 encoder/decoder.

Values longer than 255 bytes are split into repeated type entries. Decoding rejoins repeated chunks for the same type, matching HomeKit/AirPlay TLV8 use.

Summary

Functions

Decode TLV8 into a map keyed by known atoms or raw integer types.

Decode TLV8 into an explicit {:ok, map} / {:error, reason} tuple.

Encode a TLV map or key/value list.

Return the numeric TLV type id for an atom or integer type.

Return the canonical atom name for a known type id, else the raw id.

Types

pair()

@type pair() :: {type(), binary() | iodata() | non_neg_integer()}

type()

@type type() :: atom() | 0..255

Functions

decode(binary)

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

Decode TLV8 into a map keyed by known atoms or raw integer types.

decode_result(binary)

@spec decode_result(binary()) :: {:ok, map()} | {:error, term()}

Decode TLV8 into an explicit {:ok, map} / {:error, reason} tuple.

encode(values)

@spec encode(map() | [pair()]) :: binary()

Encode a TLV map or key/value list.

type_id(type)

@spec type_id(type()) :: 0..255

Return the numeric TLV type id for an atom or integer type.

type_name(type)

@spec type_name(0..255) :: atom() | 0..255

Return the canonical atom name for a known type id, else the raw id.