Files
craft-libs/crates/host
aiongg 39da1180ee Merge storytold next into memo-audit-fix
next's WordCraft port and the framework work under it (243d68e12d) take the memoized-view APIs where they meet the
branch: story values bind through StoryData::bind, value_at and pair_at (next's copy-out stories included; one held
form story still binds a copy, as its held answer is a note beside the value); next's env values (GroupLevel,
ControlPlace, RibbonLook, ScreenModeSet), IconMark and PageBandRoom derive MemoProps, and the shell entry keys the page
band's room; request_own_repaint calls become request_repaint. The collection extent next reworked (motion-owned
style context, FillHeight, ideal width by item count) moves into items_extent. The header's hosted cells join the
parts' roving group from the pass's own membership (parts_group over Cx::join_roving), as the parts' stops do. A
content-sized shell slot measures its content with the app running in it every pass. The gallery card hands the
story's output from its view's real run (StoryRun).
2026-11-20 14:58:23 +00:00
..

craft-host

The services every Craft library feature reads from the app: who the app is (AppInfo), the catalogs and current language, settings sections, command words and background jobs. The app builds one Host at startup and installs it on the egui context; features read it with Host::of(ui) and never take services as parameters.

let host = craft_host::Host::builder(craft_host::AppInfo { id: "photocraft", name: "PhotoCraft", version: "1.0" })
    .i18n(i18n)
    .settings(settings)
    .build();
host.install(&ctx); // feature `ui`

Every service has a default, so a test writes Host::builder(app).install(ctx):

Service Trait Default
Settings sections SectionStore MemorySections
Command words Commands NoCommands (English labels)
Background work Jobs ThreadJobs; InlineJobs on wasm32
Catalogs craft_i18n::I18n none (English)

queue::JobQueue runs prioritised background work with one job per key on the host's Jobs. Stories and tests step it with ManualJobs, which keeps each job until run_next runs it.

Host::install_scoped installs a host until the returned HostScope drops, then puts back the one installed before. A story swaps in a fake service this way for the time it draws.

Boundaries

  • Depends on craft-i18n, serde and toml only. Implementations depend on this crate: craft-settings implements SectionStore, craft-keymap implements Commands.
  • Feature ui adds egui for install and of. It never depends on craft-ui.
  • A settings section is a serde struct saved as one TOML table under Section::KEY.