# `Image.Plug.VariantStore`
[🔗](https://github.com/elixir-image/image_plug/blob/v0.1.0/lib/image/plug/variant_store.ex#L1)

Behaviour for variant stores.

A variant store persists `Image.Plug.Variant` records keyed by
name. Reads are expected to be cheap (every request that resolves a
variant performs one read); writes are expected to be infrequent.

The default implementation `Image.Plug.VariantStore.ETS` is
in-memory. A file-backed and a database-backed store may follow in
later milestones.

# `delete`

```elixir
@callback delete(name :: String.t(), options :: keyword()) :: :ok | {:error, :not_found}
```

Deletes a variant by name.

Returns `:ok` or `{:error, :not_found}`.

# `get`

```elixir
@callback get(name :: String.t(), options :: keyword()) ::
  {:ok, Image.Plug.Variant.t()} | {:error, :not_found}
```

Fetches a variant by name.

Returns `{:ok, variant}` or `{:error, :not_found}`.

# `list`

```elixir
@callback list(options :: keyword()) :: {:ok, [Image.Plug.Variant.t()]}
```

Lists every stored variant. The order is implementation-defined.

# `put`

```elixir
@callback put(Image.Plug.Variant.t(), options :: keyword()) ::
  {:ok, Image.Plug.Variant.t()} | {:error, term()}
```

Inserts or updates a variant.

Returns `{:ok, stored}` where `stored` may differ from the input
(for example, with `:inserted_at` / `:updated_at` populated).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
