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

View Source

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

Implementations of this seam are responsible for reading file contents from a specified path. Different reading strategies or formats can be implemented and swapped transparently (watch out for implicit coupling, it can bite).

Callback

  • read/3 – Reads data from the given path using the configured implementation and options. Returns {:ok, enumerable} 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()

read(impl, path, opts)

@callback read(impl :: t(), path :: Path.t(), opts :: keyword()) ::
  {:ok, Enumerable.t()} | {:error, term()}

version()

@callback version() :: non_neg_integer()