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

View Source

Behaviour defining how to encode records before they are written to storage.

Implementations of this seam provide the logic for transforming a record into a binary or iodata format suitable for persistence.

Callback

  • encode/3 – Encodes the given record using the seam instance. Accepts optional parameters via opts. Returns {:ok, iodata()} on success or {:error, reason} on failure.

Summary

Types

t()

@type t() :: struct()

Callbacks

default_options()

@callback default_options() :: map()

encode(t, term, keyword)

@callback encode(t(), term(), keyword()) :: {:ok, iodata()} | {:error, term()}

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()