pub struct UiDocument {
pub version: u32,
pub root: UiNode,
}Fields§
§version: u32§root: UiNodeImplementations§
Source§impl UiDocument
impl UiDocument
Sourcepub fn apply_edit(&mut self, edit: UiGraphEdit) -> Result<(), UiGraphError>
pub fn apply_edit(&mut self, edit: UiGraphEdit) -> Result<(), UiGraphError>
Apply one edit. On failure the document is left unchanged.
Sourcepub fn apply_edits(
&mut self,
edits: Vec<UiGraphEdit>,
) -> Result<(), UiGraphError>
pub fn apply_edits( &mut self, edits: Vec<UiGraphEdit>, ) -> Result<(), UiGraphError>
Apply every edit against one in-memory candidate, then publish once.
Sourcepub fn set_property(
&mut self,
id: &str,
property: &str,
value: Option<Value>,
) -> Result<(), UiGraphError>
pub fn set_property( &mut self, id: &str, property: &str, value: Option<Value>, ) -> Result<(), UiGraphError>
Set or clear one serialized property via a dotted JSON path.
Source§impl UiDocument
impl UiDocument
pub fn new(root: UiNode) -> Self
Sourcepub fn from_json(source: &str) -> Result<Self, UiGraphError>
pub fn from_json(source: &str) -> Result<Self, UiGraphError>
Parse and validate a graph before it can reach the widget tree.
Sourcepub fn to_json_pretty(&self) -> Result<String, UiGraphError>
pub fn to_json_pretty(&self) -> Result<String, UiGraphError>
Serialize the validated graph in a stable, human-readable form.
Sourcepub fn validate(&self) -> Result<(), UiGraphError>
pub fn validate(&self) -> Result<(), UiGraphError>
Check version, size, identity, accessibility, binding and geometry invariants for the complete graph.
§Errors
The first violated graph invariant.
pub fn node(&self, id: &str) -> Option<&UiNode>
pub fn node_mut(&mut self, id: &str) -> Option<&mut UiNode>
Sourcepub fn insert_child(
&mut self,
parent_id: &str,
index: usize,
node: UiNode,
) -> Result<(), UiGraphError>
pub fn insert_child( &mut self, parent_id: &str, index: usize, node: UiNode, ) -> Result<(), UiGraphError>
Insert node into a row or column at index. The graph changes only after the complete
candidate validates.
Sourcepub fn remove_node(&mut self, id: &str) -> Result<UiNode, UiGraphError>
pub fn remove_node(&mut self, id: &str) -> Result<UiNode, UiGraphError>
Remove a non-root node and return its complete subtree.
A container’s single required child cannot be removed; replace that child or remove the container instead.
Sourcepub fn replace_node(
&mut self,
id: &str,
replacement: UiNode,
) -> Result<(), UiGraphError>
pub fn replace_node( &mut self, id: &str, replacement: UiNode, ) -> Result<(), UiGraphError>
Replace a node in place, including the root, with a validated subtree.
§Errors
An unknown target, or any invariant violated by the replacement. A failure leaves the graph unchanged.
Sourcepub fn move_node(
&mut self,
id: &str,
new_parent_id: &str,
index: usize,
) -> Result<(), UiGraphError>
pub fn move_node( &mut self, id: &str, new_parent_id: &str, index: usize, ) -> Result<(), UiGraphError>
Reparent a non-root subtree into a row or column. index names the position in the
destination after the source has been detached.
§Errors
Moving the root, moving into the subtree itself, removing a container’s required child, an invalid parent or index, or another violated invariant. A failure is atomic.