返回
· 閱讀時間 1 分鐘
Save games
save::write and save::read, versioned and migrated, and a User data dock that opens saves and prefs.
- Dragos Balaur
save::write(slot, data) stores a table per player, and the User data dock opens it.

- A save is written beside its file and renamed over it, so a crash mid-save keeps the old one.
- Each file carries
[save] version. An older one runsmigrate_saveonce per version step. - The dock lists the game's user data folder and edits TOML and JSON files as trees.

save::write("slot1", #{ level: 4, coins: 120 });
let data = save::read("slot1");