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

View Source

Behaviour defining the contract for writing files within the Fact system.

Implementations of this seam are responsible for writing arbitrary values to a specified path. The behaviour allows different file writing strategies or formats to be used interchangeably.

Callback

  • write/4 – Writes a given value to the provided path using the configured implementation and options. Returns :ok on success, or {:error, reason} on failure.

Summary

Types

t()

@type t() :: struct()

Callbacks

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

write(impl, path, value, options)

@callback write(
  impl :: t(),
  path :: Path.t(),
  value :: term(),
  options :: keyword()
) :: :ok | {:error, reason :: term()}