Bundled Resources
Put application files that are not compiled into the executable in a resources/ directory: images, templates, JSON, and other data. The CLI copies that directory’s contents into the packaged app. The running app reads them from AppPaths::resource_dir(), which does not depend on the launch working directory.
To embed bytes at compile time instead, use BundledAssets and Application::assets. Custom fonts are a separate option. See Fonts.
#The resources directory
my-app/
├── resources/
│ ├── icon.png
│ ├── hero.png
│ └── copy/
│ └── template.txt
├── src/main.rs
└── quickgui.config.tsEach file keeps its path relative to resources/. resources/hero.png is installed as hero.png. resources/copy/template.txt is installed as copy/template.txt. Destination names must not replace reserved names such as fonts, AppIcon.icns, or quickgui.json.
quickgui dev and quickgui build both stage these files. A missing extra path listed in config fails the build. The resources/ directory itself is optional. Rust identity and font paths are written to quickgui.json in the same resource directory.
#Additional files
Use the resources config option to merge extra files or folders into the same packaged directory. Each extra path is copied under its basename. Do not list the project resources/ folder here; it is included automatically.
import { defineConfig } from "@quickgui/cli";
export default defineConfig({
language: "rust",
name: "My App",
identifier: "com.example.my-app",
entry: ".",
resources: ["legal/NOTICE.txt", "vendor/data"],
fonts: ["assets/MyFont.ttf"],
});legal/NOTICE.txt is installed as NOTICE.txt. vendor/data is installed as data/.
#Install locations
| Platform | Resource directory |
|---|---|
macOS .app | Contents/Resources |
Linux AppDir, AppImage, and .deb | Next to the executable (usr/bin) |
Linux install.sh tarball | Next to the executable (~/.local/<package>.app/bin) |
| Windows installer | Next to the executable in $INSTDIR |
Join packaged names onto resource_dir() at runtime; do not read from the project tree or the current working directory.
#Loading files
let hero = cx
.app_paths()
.unwrap()
.resource_dir()
.join("hero.png");
img(hero).size(160.0, 120.0)img accepts a filesystem path. Other files use the same join: std::fs::read the path, or load a compile-time BundledAssets map when the bytes should live inside the binary.
let bundle = BundledAssets::new()
.with("copy/template.txt", include_bytes!("../resources/copy/template.txt"))?;
let assets = Assets::new(bundle);Relative image paths are not resolved against the resource directory.
#Fonts
fonts lists OpenType files. The CLI copies them into fonts/ inside the resource directory and registers them from quickgui.json before the first window opens.
export default defineConfig({
language: "rust",
name: "My App",
identifier: "com.example.my-app",
entry: ".",
fonts: ["assets/MyFont.ttf"],
});You can also call Application::font with bytes or an asset path. Fonts are not a replacement for resources/: an image or JSON file still belongs in that directory, in the extra resources list, or in BundledAssets.
