# `Continuum.Snapshot`
[🔗](https://github.com/Yyeger/Continuum/blob/main/lib/continuum/snapshot.ex#L1)

Compacted history prefix for long-running workflows.

A snapshot does not capture a BEAM continuation. Workflow code still runs
from the top; the snapshot only replaces an old prefix of raw journal events
with compacted steps that validate the requested effect and return the
previously journaled result.

# `step`

```elixir
@type step() :: %{
  effect_type: atom(),
  command_id: term(),
  shape: term(),
  result: term(),
  advance_by: pos_integer()
}
```

# `t`

```elixir
@type t() :: %Continuum.Snapshot{
  run_id: binary(),
  steps_by_seq: %{required(non_neg_integer()) =&gt; step()},
  taken_at: DateTime.t(),
  through_seq: non_neg_integer(),
  version_hash: binary()
}
```

# `compact`

```elixir
@spec compact(binary(), binary(), [map()], keyword()) ::
  {:ok, t()} | {:skip, term()} | {:error, term()}
```

Compact a contiguous event list into snapshot steps.

Pass `:base` to extend an existing compatible snapshot. If the event list
ends with a pending scheduled/awaited event, the compacted snapshot stops at
the last complete step instead of covering the incomplete tail.

# `decode`

```elixir
@spec decode(binary()) :: t()
```

Decode a stored snapshot payload.

# `encode`

```elixir
@spec encode(t()) :: binary()
```

Encode a snapshot for storage.

# `encoded_size`

```elixir
@spec encoded_size(t()) :: non_neg_integer()
```

Return the encoded size in bytes.

# `format_version`

```elixir
@spec format_version() :: pos_integer()
```

Current snapshot payload format version.

---

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