Skip to main content

UiGraphHandle

Struct UiGraphHandle 

pub struct UiGraphHandle { /* private fields */ }

Implementations§

§

impl UiGraphHandle

pub fn new(document: UiDocument) -> Result<UiGraphHandle, UiGraphError>

Create a live handle after validating its complete source graph.

§Errors

Returns the graph’s validation error.

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

Parse and validate a live graph handle from JSON.

§Errors

Returns a JSON or graph validation error.

pub fn from_embedded_or_live( screen: &str, embedded: &str, ) -> Result<UiGraphHandle, UiGraphError>

Load a screen from the host’s live graph directory when one is set, otherwise from the embedded source. The native runner fills that directory from TILO_UI_GRAPH_DIR.

§Errors

Returns a JSON, I/O, or graph validation error.

pub fn open_live( path: impl Into<PathBuf>, ) -> Result<UiGraphHandle, UiGraphError>

Open a graph file and keep reloading it when its mtime advances.

Successful in-process edits are written back to the same path so the builder, tilo-app ui apply, and the running app share one document.

§Errors

Returns an I/O, JSON, or graph validation error.

pub fn live_path(&self) -> Option<PathBuf>

Path of the live on-disk graph, when this handle was opened with Self::open_live.

pub fn live_source_stale(&self) -> bool

Whether the on-disk live graph is newer than the last load/persist.

pub fn poll_live_source(&self) -> Result<bool, UiGraphError>

Reload from disk when the live file’s mtime is newer than the last load.

External edits become the new history baseline. Returns true when the in-memory document changed.

§Errors

Returns an I/O, JSON, lock, or validation error.

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

Apply a batch of tagged edits and persist when this handle is live.

§Errors

Returns a lock, edit, validation, or I/O error.

pub fn document(&self) -> Result<UiDocument, UiGraphError>

Snapshot the current source document.

§Errors

Returns UiGraphError::Poisoned if another thread panicked while holding the graph lock.

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

Serialize the current source document as formatted JSON.

§Errors

Returns a graph lock or serialization error.

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

Inspect one source node without exposing the handle’s lock or mutable live state. The returned value is an editable snapshot.

§Errors

Returns a graph lock error or UiGraphError::UnknownNode.

pub fn replace(&self, document: UiDocument) -> Result<(), UiGraphError>

Validate and atomically replace the complete source graph.

§Errors

Returns a validation or graph lock error.

pub fn can_undo(&self) -> bool

Whether the live graph has a successful edit that can be undone.

Invalid and no-op edits never enter history.

pub fn can_redo(&self) -> bool

Whether an undone edit can be reapplied.

pub fn undo(&self) -> Result<bool, UiGraphError>

Restore the graph before its most recent successful edit.

The restored document is published atomically and observed by every LiveUi and inspector sharing this handle. Returns false when the history is already at its oldest retained document.

§Errors

Returns UiGraphError::Poisoned if another thread panicked while holding the graph lock.

pub fn redo(&self) -> Result<bool, UiGraphError>

Reapply the most recently undone graph edit.

Returns false when there is no newer retained document.

§Errors

Returns UiGraphError::Poisoned if another thread panicked while holding the graph lock.

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

Forget retained undo and redo documents without changing the graph.

A builder can call this after establishing a newly loaded or saved document as its history boundary.

§Errors

Returns UiGraphError::Poisoned if another thread panicked while holding the graph lock.

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

End a continuous edit without changing the document or its history.

Call this when a text field loses focus or a drag gesture ends so a later edit using the same group key starts a new undo step.

§Errors

Returns UiGraphError::Poisoned if another thread panicked while holding the graph lock.

pub fn update_node( &self, id: &str, update: impl FnOnce(&mut UiNode), ) -> Result<(), UiGraphError>

Mutate one source node, validate the complete candidate graph, then publish it atomically. A failed edit leaves the live graph unchanged.

§Errors

Returns a graph lock, unknown-node, concurrent-edit, or validation error.

pub fn update_node_grouped( &self, id: &str, group: impl Into<String>, update: impl FnOnce(&mut UiNode), ) -> Result<(), UiGraphError>

Mutate one node as part of a continuous undo group.

Consecutive successful edits with the same group publish their live results normally but share one undo baseline. A different grouped edit, any ordinary graph mutation, undo/redo, or Self::finish_edit_group ends the group. Failed and no-op candidates never affect history.

This is intended for property typing and drag gestures; use Self::update_node for discrete operations.

§Errors

Returns a graph lock, unknown-node, concurrent-edit, or validation error.

pub fn insert_child( &self, parent_id: &str, index: usize, node: UiNode, ) -> Result<(), UiGraphError>

Atomically insert a subtree into a live row or column.

§Errors

Returns the corresponding UiDocument::insert_child error, a lock error, or UiGraphError::ConcurrentEdit.

pub fn remove_node(&self, id: &str) -> Result<UiNode, UiGraphError>

Atomically remove and return a live subtree.

§Errors

Returns the corresponding UiDocument::remove_node error, a lock error, or UiGraphError::ConcurrentEdit.

pub fn replace_node( &self, id: &str, replacement: UiNode, ) -> Result<(), UiGraphError>

Atomically replace a live subtree, including the root.

§Errors

Returns the corresponding UiDocument::replace_node error, a lock error, or UiGraphError::ConcurrentEdit.

pub fn move_node( &self, id: &str, new_parent_id: &str, index: usize, ) -> Result<(), UiGraphError>

Atomically reparent or reorder a live subtree.

§Errors

Returns the corresponding UiDocument::move_node error, a lock error, or UiGraphError::ConcurrentEdit.

pub fn widget(&self, theme: &Theme) -> Result<LiveUi, UiGraphError>

Compile the live graph into ordinary retained widgets.

§Errors

Returns a graph validation or widget-construction error.

pub fn widget_with( &self, theme: &Theme, context: UiBuildContext, ) -> Result<LiveUi, UiGraphError>

Build a live graph with process-local services such as routing.

§Errors

Returns a graph validation or widget-construction error.

Trait Implementations§

§

impl Clone for UiGraphHandle

§

fn clone(&self) -> UiGraphHandle

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

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

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,