Skip to main content

Module spec

Module spec 

Source
Expand description

v2 Spec types: flat element map with ID-keyed references.

A Spec is a top-level JSON-UI document consisting of a $schema version tag, a root element ID, and an elements map of type-erased Element values. Each Element carries a type_name: String, a props: serde_json::Value payload, a children: Vec<String> list of child IDs (not nested structures), and optional action / visible fields.

Spec::from_json and SpecBuilder::build both run the same parse-time structural validation: duplicate IDs, ID format, root existence, dangling refs, cycles, depth ≤ MAX_NESTING_DEPTH. Malformed specs surface as typed SpecError variants; from_json never panics on arbitrary input.

Structs§

DataRef
{"$data": "/path"} shape — references a JSON pointer in spec.data. Mirrors the $data key recognised by expression resolution (see expression.rs:EXPR_DATA_KEY).
EachDirective
Iteration directive on an Element: instantiate one element per row of a JSON array resolved from Spec::data.
Element
A single type-erased UI element.
ElementBuilder
Fluent builder for Element.
NestedElement
Nested-tree element form for the ergonomic SpecBuilder::element_nested API.
Spec
Top-level v2 JSON-UI document.
SpecBuilder
Fluent builder for Spec.

Enums§

SpecError
Errors returned by Spec::from_json and SpecBuilder::build.
TitleBinding
Bindable string value — either a literal or a runtime $data reference.

Constants§

MAX_NESTING_DEPTH
Maximum allowed nesting depth from the root element.
SCHEMA_VERSION
Schema version string embedded in every v2 Spec under the $schema JSON key.