static_view_locator
proc macro · ferroui-static-view-locator-macros · v0.5.0
attr macro static_view_locator!
Makes a struct a view locator generated at build time ([StaticViewLocator]).
#[static_view_locator(
generate_view_locator = true,
generate_data_template = true,
generate_runtime_type_fallback_methods = false,
generated_adapter_resolution_mode = ExactThenBaseTypesThenInterfaces,
data_template_match_types = [ViewModelBase],
)]
#[derive(Default)]
pub struct ViewLocator;
| Option | Default | Behaviour |
|---|---|---|
generate_view_factory_methods |
false |
fn try_create_view_exact(TypeId) -> Option<Ref<Control>>, unless the locator declares it |
generate_runtime_type_fallback_methods |
true |
the legacy fallback helpers, when a legacy or declared build needs them |
generate_view_locator |
false |
IViewLocator of ReactiveUI and the automatic IControlViewFor mappings (feature reactiveui) |
generate_data_template |
false |
IDataTemplate with build, match_ and the build hooks |
generated_adapter_resolution_mode |
ExactThenBaseTypesThenInterfaces |
the fallback precedence of the generated adapters |
view_model_mapping_contracts |
empty | traits with one view model type that views implement (Contract<VM>, or an associated type) |
data_template_match_types |
empty | the types (classes or traits) a resolved view model must be to match |
id |
the name of the struct | the name of the generated file, for two locators of one name in a crate |
The struct must be a top-level item of a module the build script reads (not in a function and
not under #[cfg(test)]), and the crate must run the generator in its build script.
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.