Skip to main content

Module persistence

Module persistence 

Source
Expand description

Small persistence helpers shared across platform harnesses.

Both the native (disk) and wasm (localStorage) harnesses follow the same auto-save policy: each frame, serialize the current session state, compare to the last-persisted blob, and write only when they differ AND no mouse button is currently held. The “no mouse held” guard keeps us from hammering the backend while the user is mid-drag / mid-resize.

This module owns the diff-and-save policy so hosts don’t reimplement it. Callers plug in their own serializer and persist backend via closures — AutoSave::tick takes care of the rest.

Structs§

AutoSave
Tracks the last-persisted serialized blob so the platform harness can avoid writing unchanged state every frame.