Expand description
Bundled-resource random-access API + the per-backend ResourceOpener hook (§18.3).
Bundled resources: efficient random read-only access to app-declared data, backed by each
toolkit’s native resource mechanism (DESIGN.md §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
Dir - A bundled-asset directory (§18.5): a folder’s path relative to
resource/assets/,/-separated, no trailing slash. The generatedres::assets::…tree carries one constant per folder, sharing its module’s name:res::assets::web::minisiteis theAssetDirandres::assets::web::minisite::index_htmla file within it. - Asset
Name - The bundled-data name that
resourceresolves by: the file’s path relative toresource/assets/,/-separated (a top-level file is just its 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
resource()callers 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
resource()callers 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).
Constants§
- WEIGHT_
SUFFIXES - The suffixes
Vector::weightappends to a glyph name (docs/vectors.md).
Functions§
- resolve_
asset_ dir - Resolve a data-asset directory (an
AssetDir’s/-relative path) to its on-disk location, for consumers whose local-content channel is a file URL, like the inline web view on the Apple backends (day-piece-webview’s docs/webview.md). Same probe order as file resolution:DAY_ASSET_ROOT(dev /day launch), then the bundle-relative roots. - resolve_
asset_ file - 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. - resolve_
vector_ svg - Resolve a vector name to its staged glyph SVG, for backends that render SVG natively
(docs/vectors.md):
DAY_VECTOR_SVG_ROOTunderday launch, else the packed layouts:Contents/Resources/vectors/svgin a .app,vectors/svgbeside a flat-layout exe.None(name isn’t a vector, or the layout carries no SVGs) means fall back toresolve_image_file’s raster resolution. - resolve_
vector_ xaml - Resolve a vector name to its staged XAML geometry (docs/vectors.md), the form day-xaml draws
as real
Pathgeometry: vector at any size, and tintable by brush at runtime.DAY_VECTOR_XAML_ROOTunderday launch, elsevectors/xamlbeside a flat-layout exe.None(name isn’t a vector, the art was outside the convertible subset, or the layout carries no geometry) means fall back toresolve_image_file’s raster resolution. - 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. - stage_
symbol_ svg - Day’s own drawing of
sym, written to a cache file and answered as a path. - weight_
alias - The base glyph a weight-suffixed name aliases, or
Noneif the name carries no suffix.
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.