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

Copy Markdown View Source

Validation and normalization of BTOON decoding options.

Options

  • :dictionary - a Btoon.Dictionary session dictionary shared with the encoder. StringRef ids are resolved against the session entries first, then the per-message string table carried in the envelope.
  • :schema - a Btoon.Schema used to decode a tagless schema body when the envelope does not carry the schema flag (schema negotiated out of band). When the schema flag is set, the embedded schema always wins.
  • :keys - how object keys are returned: :strings (default), :atoms (uses String.to_atom/1) or :atoms! (uses String.to_existing_atom/1).
  • :typed_arrays - :lists (default) materializes TypedArray and ObjectTable payloads as lists; :views returns the wrapper structs holding zero-copy sub-binary slices.
  • :max_depth - maximum nesting depth for tagged values (default 100).
  • :max_string_size - maximum inline string size in bytes (default 1_048_576).
  • :max_binary_size - maximum binary size in bytes (default 16_777_216).
  • :max_container_count - maximum array/object/table count (default 1_000_000).

Summary

Types

Validated decoding options.

Functions

Decodes a BTOON binary using pre-validated options.

Decodes a BTOON binary using pre-validated options, raising on error.

Returns the default validated options.

Validates decoding options.

Validates decoding options, raising ArgumentError on error.

Types

validated()

@type validated() :: %{
  dictionary: ToonEx.Btoon.Dictionary.t() | nil,
  schema: ToonEx.Btoon.Schema.t() | nil,
  keys: :strings | :atoms | :atoms!,
  typed_arrays: :lists | :views,
  max_depth: pos_integer(),
  max_string_size: pos_integer(),
  max_binary_size: pos_integer(),
  max_container_count: pos_integer()
}

Validated decoding options.

Functions

decode_validated(binary, validated_opts)

@spec decode_validated(binary(), validated()) ::
  {:ok, term()} | {:error, ToonEx.Btoon.DecodeError.t()}

Decodes a BTOON binary using pre-validated options.

This avoids re-validating options on each call, improving performance for repeated decoding with the same options.

decode_validated!(binary, validated_opts)

@spec decode_validated!(binary(), validated()) :: term()

Decodes a BTOON binary using pre-validated options, raising on error.

This avoids re-validating options on each call, improving performance for repeated decoding with the same options.

defaults()

@spec defaults() :: validated()

Returns the default validated options.

validate(opts)

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

Validates decoding options.

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

validate!(opts)

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

Validates decoding options, raising ArgumentError on error.