ToonEx.Btoon.Types (toon_ex v1.3.1)

Copy Markdown View Source

Type definitions and wrapper types for the BTOON codec.

The BTOON data model mirrors TOON: nil, booleans, integers, floats, UTF-8 strings, binary blobs, arrays and objects. Elixir strings are binaries, so two wrapper structs exist to disambiguate values that are otherwise indistinguishable:

  • Btoon.Binary – a binary value (tag 0x08) as opposed to a string (tag 0x07).
  • Btoon.TypedArray – a contiguous, homogeneous numeric buffer (tag 0x0C).
  • Btoon.ObjectTable – a columnar table of homogeneous numeric columns (tag 0x0D).

Element types

Element types are named atoms (:int8, :uint8, :int16, :uint16, :int32, :uint32, :int64, :uint64, :float32, :float64) and, for schema fields only, :null, :bool, :string, :binary, :array and :object. See Btoon.ElementType.

Summary

Types

A single decoding option.

Options accepted by Btoon.decode/2 and Btoon.decode!/2.

An element type selector atom.

Any value that can be encoded by Btoon.

A single encoding option.

Options accepted by Btoon.encode/2 and Btoon.encode!/2.

A BTOON primitive value.

Types

decode_opt()

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

A single decoding option.

decode_opts()

@type decode_opts() :: [decode_opt()]

Options accepted by Btoon.decode/2 and Btoon.decode!/2.

element_type()

@type element_type() ::
  :int8
  | :uint8
  | :int16
  | :uint16
  | :int32
  | :uint32
  | :int64
  | :uint64
  | :float32
  | :float64
  | :null
  | :bool
  | :string
  | :binary
  | :array
  | :object

An element type selector atom.

encodable()

@type encodable() ::
  nil
  | boolean()
  | integer()
  | float()
  | String.t()
  | ToonEx.Btoon.Binary.t()
  | ToonEx.Btoon.TypedArray.t()
  | ToonEx.Btoon.ObjectTable.t()
  | [encodable()]
  | %{optional(String.t()) => encodable()}

Any value that can be encoded by Btoon.

encode_opt()

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

A single encoding option.

encode_opts()

@type encode_opts() :: [encode_opt()]

Options accepted by Btoon.encode/2 and Btoon.encode!/2.

primitive()

@type primitive() ::
  nil | boolean() | integer() | float() | String.t() | ToonEx.Btoon.Binary.t()

A BTOON primitive value.