pub struct TemplateNode {
pub widget: String,
pub args: Vec<PropValue>,
pub props: Vec<(String, PropValue)>,
pub children: Vec<TemplateNode>,
}Expand description
One node in a template tree: a widget kind by name (the string the registry maps to a constructor), its props, and its children.
The name is a String, not a widget type — inflating it is the interpreter
- registry’s job (step 3). This node knows nothing about how it paints.
Fields§
§widget: StringWidget kind, e.g. "Column", "Button" — the registry key.
args: Vec<PropValue>Positional constructor arguments (the ("Hi") in Text("Hi")), in
order — they fill Widget::new(...). Hole slots for args come before
prop/child slots, matching the macro’s traversal order.
props: Vec<(String, PropValue)>key: value props, in source order.
children: Vec<TemplateNode>Nested child nodes, in source order.
Implementations§
Source§impl TemplateNode
impl TemplateNode
Sourcepub fn new(widget: impl Into<String>) -> Self
pub fn new(widget: impl Into<String>) -> Self
A leaf node of the given widget kind with no args, props, or children.
Sourcepub fn with_arg_static(self, value: StaticValue) -> Self
pub fn with_arg_static(self, value: StaticValue) -> Self
Add a static (literal) positional constructor arg.
Sourcepub fn with_arg_hole(self, index: usize) -> Self
pub fn with_arg_hole(self, index: usize) -> Self
Add a positional constructor arg bound to a hole slot.
Sourcepub fn with_static(self, key: impl Into<String>, value: StaticValue) -> Self
pub fn with_static(self, key: impl Into<String>, value: StaticValue) -> Self
Add a static (literal) prop.
Sourcepub fn with_hole(self, key: impl Into<String>, index: usize) -> Self
pub fn with_hole(self, key: impl Into<String>, index: usize) -> Self
Add a hole prop bound to index in the frame’s hole array.
Sourcepub fn with_child(self, child: TemplateNode) -> Self
pub fn with_child(self, child: TemplateNode) -> Self
Add a child node.
Trait Implementations§
Source§impl Clone for TemplateNode
impl Clone for TemplateNode
Source§fn clone(&self) -> TemplateNode
fn clone(&self) -> TemplateNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more