Skip to main content

UiDocument

Struct UiDocument 

Source
pub struct UiDocument {
    pub version: u32,
    pub root: UiNode,
}

Fields§

§version: u32§root: UiNode

Implementations§

Source§

impl UiDocument

Source

pub fn apply_edit(&mut self, edit: UiGraphEdit) -> Result<(), UiGraphError>

Apply one edit. On failure the document is left unchanged.

Source

pub fn apply_edits( &mut self, edits: Vec<UiGraphEdit>, ) -> Result<(), UiGraphError>

Apply every edit against one in-memory candidate, then publish once.

Source

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

Source

pub fn new(root: UiNode) -> Self

Source

pub fn from_json(source: &str) -> Result<Self, UiGraphError>

Parse and validate a graph before it can reach the widget tree.

Source

pub fn to_json_pretty(&self) -> Result<String, UiGraphError>

Serialize the validated graph in a stable, human-readable form.

Source

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.

Source

pub fn node(&self, id: &str) -> Option<&UiNode>

Source

pub fn nodes(&self) -> Vec<&UiNode>

Every source node in depth-first builder order.

Source

pub fn node_mut(&mut self, id: &str) -> Option<&mut UiNode>

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for UiDocument

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UiDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UiDocument

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for UiDocument

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for UiDocument

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for UiDocument

Auto Trait Implementations§

§

impl Forget for UiDocument

§

impl Freeze for UiDocument
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<UiNode>: Freeze, *const UiNode is !null: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze,

§

impl Move for UiDocument

§

impl RefUnwindSafe for UiDocument

§

impl Send for UiDocument
where RawVecInner: Send, BoxRaw<UiNode>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl Sync for UiDocument
where RawVecInner: Sync, BoxRaw<UiNode>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl Unpin for UiDocument
where *const u8 is !null: Unpin, Box<UiNode>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for UiDocument

§

impl UnwindSafe for UiDocument
where RawVecInner: UnwindSafe, BoxRaw<UiNode>: UnwindSafe, BTreeMap<String, Value>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.