idle_save library

Versioned save + migration chain + integrity helpers for idle_core states.

Classes

CanonicalJsonSaveCodec
JSON codec that canonicalizes maps by sorting keys.
Checksum
Computes SHA-256 checksums for payload integrity.
FileStore
Web fallback for file-backed persistence.
JsonSafe
Validates that payloads only contain JSON-safe values.
JsonSaveCodec
JSON codec using dart:convert jsonEncode/jsonDecode.
LoadFailure
Failed load result.
LoadResult<T>
Base type for load results.
LoadSuccess<T>
Successful load result.
MemoryStore
In-memory store for tests or samples.
Migration
Single schema migration from from to to.
MigrationContext
Context provided to migrations for deterministic data.
MigrationResult
Result of applying a migration chain.
Migrator
Applies ordered migrations and validates continuity.
SaveChangeSet
Records what changed in a save boundary.
SaveCodec
Encodes and decodes JSON-safe payload maps.
SaveContext
Context describing why a save was requested.
SaveEnvelope
Wrapper around a JSON-safe payload with schema metadata.
SaveFailure
Failed save result.
SaveManager<T>
Coordinates saving, loading, and migrations for a payload type.
SaveReason
Named reason for a save boundary.
SaveResult
Base type for save results.
SaveStore
Abstract persistence layer for save data.
SaveSuccess
Successful save result.

Enums

LoadFailureReason
Reason for a failed load operation.
SaveFailureReason
Reason for a failed save operation.

Functions

idleCoreSaveManager<S extends IdleState>({required SaveStore store, required SaveCodec codec, required Migrator migrator, required IdleStateDecoder<S> decoder, SaveStore? backupStore, TickClock? tickClock, Clock? clock, Checksum checksum = const Checksum(), bool useChecksum = true, bool verifyChecksum = true, bool validatePayload = true}) SaveManager<S>
Builds a SaveManager wired for idle_core IdleState types.

Typedefs

IdleStateDecoder<S extends IdleState> = S Function(Map<String, dynamic> json)
Decoder for an IdleState from a JSON-safe map.
MigrationFn = Map<String, dynamic> Function(Map<String, dynamic> payload)
Function that transforms a payload into the next schema version.
MigrationFnWithContext = Map<String, dynamic> Function(Map<String, dynamic> payload, MigrationContext context)
Function that transforms a payload into the next schema version with context.