ToonEx.Btoon.Encode.Options (toon_ex v1.3.1)

Copy Markdown View Source

Validation and normalization of BTOON encoding options.

Options

  • :dictionary - a Btoon.Dictionary session dictionary, or nil. Strings present in the dictionary are encoded as StringRef.
  • :string_table - :auto (default) builds a per-message string table for strings absent from the session dictionary; :off writes full strings instead.
  • :no_string_table - true omits the per-message string table entirely. Requires :dictionary to be set. When enabled, all strings MUST be in the session dictionary or written inline. Overrides :string_table.
  • :schema - a Btoon.Schema to encode in schema mode, or nil.
  • :schema_id_uint16 - true encodes the schema ID as UInt16 (2 bytes) instead of UInt32 (4 bytes). Requires :schema to be set.
  • :typed_arrays - true (default) encodes homogeneous numeric lists as TypedArray (tag 0x0C).
  • :object_tables - true (default) encodes homogeneous object lists as columnar ObjectTable (tag 0x0D).

Summary

Types

Validated encoding options.

Functions

Returns the default validated options.

Validates encoding options.

Validates encoding options, raising ArgumentError on error.

Types

validated()

@type validated() :: %{
  dictionary: ToonEx.Btoon.Dictionary.t() | nil,
  string_table: :auto | :off,
  no_string_table: boolean(),
  schema: ToonEx.Btoon.Schema.t() | nil,
  schema_id_uint16: boolean(),
  typed_arrays: boolean(),
  object_tables: boolean()
}

Validated encoding options.

Functions

defaults()

@spec defaults() :: validated()

Returns the default validated options.

validate(opts)

@spec validate(keyword()) :: {:ok, validated()} | {:error, String.t()}

Validates encoding options.

Returns {:ok, validated} or {:error, message}.

validate!(opts)

@spec validate!(keyword()) :: validated()

Validates encoding options, raising ArgumentError on error.