Skip to main content

Module store

Module store 

Source
Expand description

Where the settings’ values are kept: a contract the host provides (SettingsStore), which the Settings app calls. egui-pop holds no storage location and no default store: without one (super::Admin::attach_store), the values live in memory for the session and the Settings window says so.

  • Load: each scope the store holds is read when the store is attached (app, and a host scope when it is offered, or reloaded with super::Admin::reload); the values it gives become the layer’s, or the user’s own for app.
  • Save: what changes in a scope the store holds is sent as the values changed, away from the UI thread (a worker thread; on the web, at once). A failing save is shown in the Settings window until a save of that scope succeeds.
  • Watch: a store tells the app of changes made elsewhere (another client, another process); they are applied at the next pass, and nothing is written back.
  • Claims: a store holds the settings it claims, the others stay with the app. CompositeStore routes each setting to the first handler claiming it, the rest to a default store.

FileStore keeps a scope in a JSON file whose path the host gives; MemoryStore keeps them in memory (tests, demos, a handler for the settings that must not outlive the session).

Structs§

CompositeStore
An ordered list of handlers and a default store. Each setting belongs to the first handler claiming it, else to the default; loads merge what each one owns, saves are split by owner, and every handler’s changes are followed. A setting claimed by two handlers is reported once (SettingsStore::problems); the first wins.
FileStore
A store keeping each scope in a JSON file (an object of setting ids to values) at the path the host gives. It knows no folder of its own: a scope without a path is not kept. Saving reads the file, applies the changes and replaces it whole (written beside it, then renamed). It sees no change made elsewhere.
MemoryStore
A store keeping its scopes in memory: a handler for settings that last the session, a stand-in in tests. MemoryStore::change stands for a change made elsewhere: its watchers are told. Clones share the values.

Traits§

SettingsStore
Where the settings are kept, as the host provides it. Every method may be called from a thread other than the UI’s: save always is, except on the web.

Functions§

apply
Applies changes to values.
diff
What changed from before to after.

Type Aliases§

Changes
Values changed in a scope, by setting id: Some its new value, None taken back (back to the default, or to the layer under it).
OnChange
Called by a store when values change elsewhere: the scope and what changed. May be called from any thread.
Values
A scope’s values, by setting id (appearance.theme, not its store path).