Expand description
Binding system types
This module provides the core abstraction for data binding in Dampen.
§Overview
The binding system allows XML expressions like {counter} or {user.name}
to access fields from Rust structs at runtime.
§Key Types
UiBindable- Trait implemented by models to expose fieldsBindingValue- Runtime value representationToBindingValue- Trait for converting Rust types to BindingValue
§Example
use dampen_core::{UiBindable, BindingValue};
#[derive(Default)]
struct Model {
count: i32,
name: String,
}
impl UiBindable for Model {
fn get_field(&self, path: &[&str]) -> Option<BindingValue> {
match path {
["count"] => Some(BindingValue::Integer(self.count as i64)),
["name"] => Some(BindingValue::String(self.name.clone())),
_ => None,
}
}
fn available_fields() -> Vec<String> {
vec!["count".to_string(), "name".to_string()]
}
}Enums§
- Binding
Value - Value returned from a binding evaluation
Traits§
- ToBinding
Value - Trait for converting types to BindingValue
- UiBindable
- Trait for types that expose bindable fields