Rendro.Storage behaviour (Rendro v0.2.0)

Copy Markdown View Source

Behavior for artifact storage adapters.

Defines the contract for persisting Rendro.Artifact structures to external storage systems (S3, local disk, database, etc.) without coupling core rendering logic to any specific storage implementation.

Summary

Callbacks

Deletes a stored artifact by its identifier.

Retrieves a stored artifact by its identifier.

Persists an artifact.

Callbacks

delete(t, keyword)

@callback delete(
  String.t(),
  keyword()
) :: :ok | {:error, term()}

Deletes a stored artifact by its identifier.

Returns :ok on successful deletion, or {:error, reason}.

get(t, keyword)

@callback get(
  String.t(),
  keyword()
) :: {:ok, Rendro.Artifact.t()} | {:error, term()}

Retrieves a stored artifact by its identifier.

Returns {:ok, Artifact.t()} if found, or {:error, :not_found} / {:error, reason}.

put(t, keyword)

@callback put(
  Rendro.Artifact.t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}

Persists an artifact.

Implementations must return {:ok, identifier} where identifier is a stable string/URI referencing the stored document. They may also return {:error, reason}.