Module binding

Module binding 

Source
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

§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§

BindingValue
Value returned from a binding evaluation

Traits§

ToBindingValue
Trait for converting types to BindingValue
UiBindable
Trait for types that expose bindable fields