Expand description
Rust value converters for data binding.
A Converter wraps a Noesis::BaseValueConverter subclass whose
TryConvert / TryConvertBack forward into a Rust ValueConverter. This
is what real bindings need: mapping a source value to a target-shaped value
(bool → text/Visibility, number formatting, enum mapping, …) as the data
crosses the binding.
Binding values cross the FFI as boxed Noesis::BaseComponent*. The callback
receives the source value and the optional
ConverterParameter as ConvertArgs (unbox them with
ConvertArg::as_i32 / as_bool /
as_f64 / as_str), and returns
a Converted the trampoline re-boxes for Noesis (or None to signal
UnsetValue, so the binding falls back to its FallbackValue / the
property default).
§Reaching a binding
Two ways, both wired the same on the C++ side:
- Code-built binding, the primary path for Rust integration:
Binding::new("Path").converter(&converter)thenset_binding. Seecrate::binding. - XAML resource: insert the converter into an element’s
ResourceDictionarywithadd_resourceand author{Binding Path, Converter={StaticResource Key}}in XAML.
§Lifetime
Converter holds the caller’s +1 reference, released on drop. If a
binding still references the converter (the common case while it’s wired
onto a live element), the underlying object (and the boxed handler) stay
alive until that reference also drops. The handler is freed exactly once, by
the C++ destructor, after the last reference goes away.
§Threading
convert / convert_back fire from inside Noesis’s binding pump on whatever
thread drives the view. The handler is stored behind Send; keep the work
small.
Structs§
- Convert
Arg - A borrowed, boxed binding value handed to a
ValueConverter.None-valued (the bound source produced null / the control supplied no parameter) reportsis_none; the typed accessors returnNonewhen the boxed runtime type doesn’t match. - Converter
- A Rust-backed
IValueConverter. Owns a+1reference released on drop. Attach it to a binding withBinding::converter, or insert it into an element’s resources withadd_resource.
Enums§
- Converted
- A value a
ValueConverterproduces. The trampoline re-boxes it into theNoesis::BaseComponent*the binding engine expects.
Traits§
- Value
Converter - Rust-side conversion logic.
convertmaps a binding source value to the target;convert_back(only reached on aTwoWay/OneWayToSourcebinding) maps a target value back to the source. ReturningNonesignalsUnsetValue.