pub struct SpecBuilder { /* private fields */ }Expand description
Fluent builder for Spec.
Implementations§
Source§impl SpecBuilder
impl SpecBuilder
Sourcepub fn title_binding(self, path: impl Into<String>) -> Self
pub fn title_binding(self, path: impl Into<String>) -> Self
Set the document title to a {"$data": "/path"} binding.
Sourcepub fn root(self, id: impl Into<String>) -> Self
pub fn root(self, id: impl Into<String>) -> Self
Explicitly set the root element ID.
If omitted, the root defaults to the ID of the first element added.
Sourcepub fn element(self, id: impl Into<String>, el: ElementBuilder) -> Self
pub fn element(self, id: impl Into<String>, el: ElementBuilder) -> Self
Add an element to the spec. The first call (absent an explicit
SpecBuilder::root) establishes the root.
Sourcepub fn element_nested(self, id: impl Into<String>, el: NestedElement) -> Self
pub fn element_nested(self, id: impl Into<String>, el: NestedElement) -> Self
Add an element AND its nested children in a single call.
Children are flattened to the canonical flat Spec.elements map with
IDs auto-generated by structural position: {parent_id}-0,
{parent_id}-1, …, and so on recursively
({parent_id}-0-0, {parent_id}-0-1, …).
The first .element_nested call (absent an explicit
SpecBuilder::root) establishes the root, just like
SpecBuilder::element.
§D-07 contract
The runtime Spec shape is unchanged. After this method returns,
the nested form is gone — the spec is the canonical flat element map.