Skip to main content

UiDocument

Struct UiDocument 

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

Fields§

§version: u32§root: UiNode

Implementations§

§

impl UiDocument

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>

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>

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

pub fn new(root: UiNode) -> UiDocument

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>

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>

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 nodes(&self) -> Vec<&UiNode>

Every source node in depth-first builder order.

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>

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>

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>

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>

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

§

fn clone(&self) -> UiDocument

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
§

impl Debug for UiDocument

§

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

Formats the value using the given formatter. Read more
§

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

§

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

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

impl PartialEq for UiDocument

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for UiDocument

§

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

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

impl UiDocumentExt for UiDocument

§

fn build(&self, theme: &Theme) -> Result<Box<dyn Widget>, UiGraphError>

Build the retained widget subtree represented by this graph. Read more
§

fn build_with( &self, _theme: &Theme, context: &UiBuildContext, ) -> Result<Box<dyn Widget>, UiGraphError>

Build with process-local services such as screen navigation. Read more
§

impl StructuralPartialEq for UiDocument

Auto Trait Implementations§

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,