# `ExWapp.AppState.Engine.State`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/appstate/engine/state.ex#L1)

Persistence helpers for app-state hash-chain metadata.

The app-state protocol tracks a per-collection LTHash version and a mutation
MAC cache. This module keeps those storage concerns separate from transport
and decoding logic.

# `hash_state`

```elixir
@type hash_state() :: %{version: non_neg_integer(), hash: binary()}
```

# `all_collections`

```elixir
@spec all_collections() :: [String.t()]
```

Returns the collection names tracked by the app-state engine.

# `get_collection_state`

```elixir
@spec get_collection_state(struct(), String.t()) :: {:ok, hash_state(), map()}
```

Loads the saved hash state and mutation MACs for one collection.

# `persist_collection_state`

```elixir
@spec persist_collection_state(struct(), String.t(), hash_state(), map()) :: :ok
```

Persists the current hash state and mutation MACs for one collection.

# `reset_collection_state`

```elixir
@spec reset_collection_state(struct(), String.t()) :: :ok
```

Drops a collection's stored version, hash and mutation MACs so the next
fetch starts over from a snapshot.

---

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