← Versioned state

State.MigrationSuccess

luastra/state

State.MigrationSuccess represents the successful branch of a discriminated SDK result. Its value and success-specific fields are safe to read only after the shared success tag has narrowed the union.

Before you use it

Add luastra/state to this module's dependencies in luastra.json, then import it with require("luastra/state"). No capability is required for encoding, decoding, or migration. Persistence additionally needs luastra/host plus storage.get and storage.set.

How it fits

The type describes string fields, migration functions, or tagged decode/migration results.

When to use it

Use State.MigrationSuccess after narrowing the related result with success == true. Only this branch guarantees access to the decoded value and other success-specific fields.

Fields or definition

ParameterType / valuesDescription
successtrueDiscriminator that must be checked before reading branch-specific fields.
versionnumberExplicit contract version used to validate or migrate the serialized value.
fieldsFieldsValidated bounded field map carried by the decoded or migrated value.
encodedstringDeterministic snapshot string produced after a successful migration.
errornilBounded failure information, or nil on the successful branch.

SDK type flow

Produced by

State.migrate

What happens next

A checked snapshot or result annotation.

Failures and fixes

Malformed data, wrong versions, missing migration steps, excessive size, or non-string fields remain explicit failure branches. Do not silently replace corrupt security- or domain-sensitive values with defaults.

Availability

Public-source alpha API in 0.5.0-alpha; persistence support is host-dependent.

Exact declaration

export type MigrationSuccess = { success: true, version: number, fields: Fields, encoded: string, error: nil }

Continue learning

Prerequisites

State.Migration

Complete inventory

View all pages in Versioned state
← Previous: State.MigrationErrorNext: State.MigrationFailure →