#[repr(C)]pub struct AppConfig {
pub log_level: AppLogLevel,
pub enable_visual_panic_hook: bool,
pub enable_logging_on_panic: bool,
pub enable_tab_navigation: bool,
pub termination_behavior: AppTerminationBehavior,
pub icon_provider: IconProviderHandle,
pub bundled_fonts: NamedFontVec,
pub font_loading: FontLoadingConfig,
pub mock_css_environment: OptionCssMockEnvironment,
pub system_style: SystemStyle,
pub component_libraries: ComponentLibraryVec,
pub routes: RouteVec,
}Expand description
Configuration for optional features, such as whether to enable logging or panic hooks
Fields§
§log_level: AppLogLevelIf enabled, logs error and info messages.
Default is LevelFilter::Error to log all errors by default
enable_visual_panic_hook: boolIf the app crashes / panics, a window with a message box pops up.
Setting this to false disables the popup box.
enable_logging_on_panic: boolIf this is set to true (the default), a backtrace + error information
gets logged to stdout and the logging file (only if logging is enabled).
(STUB) Whether keyboard navigation should be enabled (default: true). Currently not implemented.
termination_behavior: AppTerminationBehaviorDetermines what happens when all windows are closed. Default: EndProcess (terminate when last window closes).
icon_provider: IconProviderHandleIcon provider for the application. Register icons here before calling App::run(). Each window will clone this provider (cheap, Arc-based).
bundled_fonts: NamedFontVecFonts bundled with the application. These fonts are loaded into memory and take priority over system fonts.
font_loading: FontLoadingConfigConfiguration for how system fonts should be loaded. Default: LoadAllSystemFonts (scan all system fonts at startup)
mock_css_environment: OptionCssMockEnvironmentOptional mock environment for CSS evaluation.
When set, this overrides the auto-detected system properties (OS, theme, etc.) for CSS @-rules and dynamic selectors. This is useful for:
- Testing OS-specific styles on a different platform
- Screenshot testing with consistent environment
- Previewing how the app looks on different systems
Default: None (use auto-detected system properties)
system_style: SystemStyleSystem style detected at startup (theme, colors, fonts, etc.)
This is detected once at AppConfig::create() and passed to all windows.
You can override this after creation to use a custom system style,
for example to test how your app looks on a different platform.
component_libraries: ComponentLibraryVecComponent libraries registered at startup.
Use add_component() to register individual components, or
add_component_library() to register entire libraries.
User-registered (and built-in) component libraries.
The 52 built-in HTML elements are automatically registered by
AppConfig::create() via register_builtin_components.
Additional libraries can be added with add_component_library.
routes: RouteVecRegistered routes mapping URL patterns to layout callbacks.
Cross-platform: on desktop, the active route determines which layout callback runs. On web, routes map to HTTP endpoints and browser URLs.
The first route (or "/") is the default. Use add_route() to register.
Implementations§
Source§impl AppConfig
impl AppConfig
pub fn create() -> Self
Sourcepub fn with_mock_environment(self, env: CssMockEnvironment) -> Self
pub fn with_mock_environment(self, env: CssMockEnvironment) -> Self
Create config with a mock CSS environment for testing
This allows you to simulate how your app would look on a different OS, with a different theme, language, or accessibility settings.
§Example
let config = AppConfig::create()
.with_mock_environment(CssMockEnvironment {
os: OptionOsCondition::Some(OsCondition::Linux),
theme: OptionThemeCondition::Some(ThemeCondition::Dark),
..Default::default()
});Sourcepub fn add_component<R: Into<RegisterComponentFn>>(
&mut self,
library: AzString,
register_fn: R,
)
pub fn add_component<R: Into<RegisterComponentFn>>( &mut self, library: AzString, register_fn: R, )
Register a single component into a named library.
Calls register_fn immediately and adds the returned ComponentDef
to the library named library. If no library with that name exists,
a new one is created. If a component with the same id.name already
exists in the library, it is replaced.
§C API
AzAppConfig_addComponent(&config, AzString_fromConstStr("mylib"), my_register_fn);Sourcepub fn add_component_library<R: Into<RegisterComponentLibraryFn>>(
&mut self,
name: AzString,
register_fn: R,
)
pub fn add_component_library<R: Into<RegisterComponentLibraryFn>>( &mut self, name: AzString, register_fn: R, )
Register an entire component library.
Calls register_fn immediately and adds the returned
ComponentLibrary to the config. Uses name as the library name
(overriding whatever the function sets). If a library with the same
name already exists, it is replaced wholesale.
§C API
AzAppConfig_addComponentLibrary(&config, AzString_fromConstStr("vendor"), my_lib_fn);Sourcepub fn add_route<P: Into<AzString>, L: Into<LayoutCallback>>(
&mut self,
pattern: P,
layout_fn: L,
)
pub fn add_route<P: Into<AzString>, L: Into<LayoutCallback>>( &mut self, pattern: P, layout_fn: L, )
Register a route mapping a URL pattern to a layout callback.
On web: each route becomes an HTTP endpoint. On desktop: the first
route (or "/") is the initial layout, and CallbackInfo::switch_route()
swaps the active callback.
§C API
AzAppConfig_addRoute(&config, AzString_fromConstStr("/user/:id"), layout_user);Sourcepub fn match_route_for_path(&self, path: &str) -> Option<(&Route, RouteMatch)>
pub fn match_route_for_path(&self, path: &str) -> Option<(&Route, RouteMatch)>
Find the route matching a given URL path.
Returns the matched Route and a RouteMatch with extracted parameters.