Struct UiDocument
pub struct UiDocument {
pub version: u32,
pub root: UiNode,
}Fields§
§version: u32§root: UiNodeImplementations§
§impl UiDocument
impl UiDocument
pub 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.
§Errors
Returns the structural, property, or validation error from the edit.
pub 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.
§Errors
Returns the first failing edit. The document is unchanged on failure.
pub 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.
§Errors
Returns an error when the node is missing, the path is invalid, or the resulting node fails schema validation.
§impl UiDocument
impl UiDocument
pub fn new(root: UiNode) -> UiDocument
pub fn from_json(source: &str) -> Result<UiDocument, UiGraphError>
pub fn from_json(source: &str) -> Result<UiDocument, UiGraphError>
Parse and validate a graph before it can reach the widget tree.
§Errors
Returns a JSON decoding or graph-validation error.
pub 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.
§Errors
Returns a graph-validation or JSON encoding error.
pub 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
Returns the first violated graph invariant.
pub fn node(&self, id: &str) -> Option<&UiNode>
pub fn node_mut(&mut self, id: &str) -> Option<&mut UiNode>
pub 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 is changed
only after the complete candidate validates.
§Errors
Returns an error for an unknown/non-collection parent, an out-of-range index, or any graph invariant violated by the inserted subtree.
pub 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.
§Errors
Returns an error for the root, an unknown node, or a container’s required child. A failure leaves the graph unchanged.
pub 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
Returns an error for an unknown target or any invariant violated by the replacement. A failure leaves the graph unchanged.
pub 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
Returns an error when moving the root, moving into the subtree itself, removing a container’s required child, selecting an invalid parent or index, or violating another graph invariant. A failure is atomic.
Trait Implementations§
§impl Clone for UiDocument
impl Clone for UiDocument
§fn clone(&self) -> UiDocument
fn clone(&self) -> UiDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for UiDocument
impl Debug for UiDocument
§impl<'de> Deserialize<'de> for UiDocument
impl<'de> Deserialize<'de> for UiDocument
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<UiDocument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<UiDocument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for UiDocument
impl PartialEq for UiDocument
§impl Serialize for UiDocument
impl Serialize for UiDocument
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl UiDocumentExt for UiDocument
impl UiDocumentExt for UiDocument
§fn build(&self, theme: &Theme) -> Result<Box<dyn Widget>, UiGraphError>
fn build(&self, theme: &Theme) -> Result<Box<dyn Widget>, UiGraphError>
§fn build_with(
&self,
_theme: &Theme,
context: &UiBuildContext,
) -> Result<Box<dyn Widget>, UiGraphError>
fn build_with( &self, _theme: &Theme, context: &UiBuildContext, ) -> Result<Box<dyn Widget>, UiGraphError>
impl StructuralPartialEq for UiDocument
Auto Trait Implementations§
impl Freeze for UiDocument
impl RefUnwindSafe for UiDocument
impl Send for UiDocument
impl Sync for UiDocument
impl Unpin for UiDocument
impl UnsafeUnpin for UiDocument
impl UnwindSafe for UiDocument
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more