Fact.Seam.Decoder behaviour (Fact v0.2.1)

View Source

Behaviour defining how to decode stored records back into Elixir terms.

Implementations of this seam provide the logic for transforming a binary or iodata record retrieved from storage into a usable Elixir data structure.

Callback

  • decode/3 – Decodes the given binary value using the seam instance. Accepts optional parameters via opts. Returns {:ok, decoded} on success or {:error, reason} on failure.

Summary

Types

t()

@type t() :: struct()

Callbacks

decode(impl, value, opts)

@callback decode(impl :: t(), value :: binary(), opts :: keyword()) ::
  {:ok, decoded :: term()} | {:error, reason :: term()}

default_options()

@callback default_options() :: map()

family()

@callback family() :: atom()

id()

@callback id() :: {atom(), non_neg_integer()}

init(map)

@callback init(map()) :: struct() | {:error, term()}

normalize_options(map)

@callback normalize_options(map()) :: {:ok, map()} | {:error, term()}

option_specs()

@callback option_specs() :: %{required(atom()) => map()}

prepare_options(map)

@callback prepare_options(map()) :: map()

version()

@callback version() :: non_neg_integer()