Skip to main content

Module storage

Module storage 

Source
Expand description

Persistence: a game’s saves and the player’s settings go through Storage, so the UI stays pure. The platform supplies the real implementation (files, the browser’s localStorage, a console’s own files); MemoryStorage is for tests and the test harness.

Structs§

MemoryStorage
An in-memory Storage, for tests and the harness. Nothing persists past the process.

Enums§

StorageError
Why a Storage operation failed.

Constants§

MAX_KEY_LEN
Longest key Storage accepts, in bytes.

Traits§

PowerCutRig
A Storage over a fake of its medium, which can lose the power: what a backend writes to run power_cut_suite.
Storage
A place to persist small named blobs of text (RON documents, typically): files on native, localStorage on web.

Functions§

conformance_suite
A conformance suite every Storage implementation must pass, shared by this crate’s own tests and the platforms’ implementations.
is_valid_key
Whether key matches ^[a-z0-9_-]{1,64}$: lowercase ASCII letters, digits, _ and -, 1 to MAX_KEY_LEN bytes.
power_cut_suite
Cuts the power in a write over an old value, a first write and a delete, after each number of operations of the medium in turn, until the operation finishes, and checks what the storage reads after each restart. Panics with the promise broken, the operation and the cut.