Strict, versioned serialization for durable Spectre state.
The codec accepts JSON text or database-style maps with string keys. It validates state, effect, and awaitable lifecycle enums and rejects unknown fields instead of silently dropping them. Arbitrary nested terms are encoded through explicit tagged JSON values; decoding never creates atoms.
Summary
Functions
Decodes JSON text or a string/atom-keyed persistence map into validated state.
Decodes state or raises for trusted boot-time configuration paths.
Encodes state into a JSON-safe map whose public schema uses string keys.
Encodes state as JSON.
Functions
@spec decode(String.t() | map()) :: {:ok, Spectre.State.t()} | {:error, term()}
Decodes JSON text or a string/atom-keyed persistence map into validated state.
@spec decode!(String.t() | map()) :: Spectre.State.t()
Decodes state or raises for trusted boot-time configuration paths.
@spec encode(Spectre.State.t()) :: {:ok, map()} | {:error, term()}
Encodes state into a JSON-safe map whose public schema uses string keys.
@spec encode_json(Spectre.State.t()) :: {:ok, String.t()} | {:error, term()}
Encodes state as JSON.