Expand description
Bundled-resource random-access API + the per-backend opener seam (§18.3). Bundled resources — efficient random read-only access to app-declared data, backed by each toolkit’s native resource mechanism (DESIGN §18.3).
day build stages the files declared under a project’s assets/ (and images/) into each
platform’s native resource store, uncompressed where possible so the runtime can hand back a
zero-copy view. At runtime resource("name") returns a Resource whose bytes are borrowed
directly from that store — an mmap of a bundle file on Apple, the NDK AAssetManager buffer on
Android, g_resources_lookup_data on GTK, QResource::data on Qt, the rawfile fd on ArkUI.
The active backend registers its opener once via set_resource_opener; if none is registered
(desktop dev, host tests, and the Apple backends, whose native mechanism is a bundle file) the
default opener mmaps the file resolved from DAY_ASSET_ROOT or the app bundle.
Structs§
- Asset
Name - The bundled-data name that
resourceresolves by (the full file name, extension included). - Font
Family - The family name of a bundled custom font, feeding
Font::custom. Holds a&'static str(soFontstaysCopy); generatedres::fonts::…constants supply it. The untypedFont::Custom(&'static str, f64)variant remains the escape hatch for a family known another way. - Image
Name - The bundled-image name that
imagecallers resolve by (the file stem). - Resource
- A handle to a bundled resource’s bytes with efficient random read-only access.
- Vector
Name - The bundled-vector name that
vectorcallers resolve by (docs/vectors.md): the stem of aresource/vectors/SVG (or.symbolsetbundle). Vectors and images share one per-backend resolution namespace — staging guarantees every vector name resolves as whatever form that backend loads natively (a VectorDrawable, a catalog entry, a rasterized PNG).
Functions§
- resolve_
image_ file - Resolve an image name to an on-disk file, for the file-loading backends (AppKit/GTK/Qt, and the
desktop/dev path). Probes
DAY_IMAGE_ROOT(the project’simages/underday launch) first, thenDAY_ASSET_ROOTand the bundle, trying the bare name and, if it has no extension, each known image extension. Native-pipeline backends (iOSAssets.car, AndroidR, …) resolve by name through their own store and do not use this. - resource
- Open a bundled resource by name for efficient random read-only access.
- set_
resource_ opener - Register the active backend’s resource opener (Android
AAssetManager, GTKGResource, QtQResource, ArkUI rawfile, …). Called once during backend init. A second call is ignored, so a backend that shares the default file opener need not call this at all.
Type Aliases§
- Resource
Opener - A backend’s resource opener: maps a declared name (e.g.
"stations.json") to its bytes, orNoneif there is no such resource.