pub struct Composition<A>where
A: Applier + 'static,{ /* private fields */ }Expand description
Re-export the UI crate so applications can depend on a single crate.
Implementations§
Source§impl<A> Composition<A>where
A: Applier + 'static,
impl<A> Composition<A>where
A: Applier + 'static,
pub fn new(applier: A) -> Composition<A>
pub fn with_runtime(applier: A, runtime: Runtime) -> Composition<A>
Sourcepub fn root_key(&self) -> Option<u64>
pub fn root_key(&self) -> Option<u64>
Returns the root group key captured from the most recent render() call,
or None before the first render.
pub fn set_retention_policy(&self, policy: RetentionPolicy)
pub fn take_root_render_request(&mut self) -> bool
pub fn request_root_render(&mut self)
pub fn render( &mut self, key: u64, content: impl FnMut(), ) -> Result<(), NodeError>
Sourcepub fn render_stable(
&mut self,
key: u64,
content: impl FnMut(),
) -> Result<(), NodeError>
pub fn render_stable( &mut self, key: u64, content: impl FnMut(), ) -> Result<(), NodeError>
Perform a root render and continue replaying any resulting root-render requests until the composition reaches a stable fixpoint.
Sourcepub fn reconcile(
&mut self,
key: u64,
content: impl FnMut(),
) -> Result<bool, NodeError>
pub fn reconcile( &mut self, key: u64, content: impl FnMut(), ) -> Result<bool, NodeError>
Process invalid scopes and any resulting root-render requests until the composition reaches a stable fixpoint for the supplied root content.
Sourcepub fn should_render(&self) -> bool
pub fn should_render(&self) -> bool
Returns true if composition needs to process invalid scopes (recompose).
This checks both:
has_updates(): composition scopes that were invalidated by state changesneeds_frame(): animation callbacks that may have pending work
Note: For scroll performance, ensure scroll state changes use Cell<T> instead
of MutableState<T> to avoid triggering recomposition on every scroll frame.
Sourcepub fn should_recompose(&self) -> bool
pub fn should_recompose(&self) -> bool
Whether any composition scope is actually invalid, i.e. whether running the composable tree could produce a different result than last time.
Deliberately excludes Runtime::needs_frame, which Self::should_render
includes. An armed frame callback means the runtime owes someone a
tick - a future to resume, a dispatcher to drain - and every app with a
game loop or a polling effect has one armed at all times. Re-running the
composition for it recomposes a tree that nothing invalidated. Callers
deciding “should I tick” want Self::should_render; callers deciding
“should I recompose” want this.
It is only meaningful after the frame callbacks have been drained: a callback that writes state invalidates its readers as it runs, so the answer is a question about work already discovered, not work still to come.
pub fn runtime_handle(&self) -> RuntimeHandle
pub fn applier_mut(&mut self) -> ApplierGuard<'_, A>
pub fn root(&self) -> Option<usize>
pub fn debug_dump_slot_table_groups( &self, ) -> Vec<(usize, u64, Option<usize>, usize)>
pub fn debug_dump_slot_entries(&self) -> Vec<SlotDebugEntry>
pub fn slot_table_heap_bytes(&self) -> usize
pub fn debug_slot_table_stats(&self) -> SlotTableDebugStats
pub fn debug_slot_snapshot(&self) -> SlotDebugSnapshot
pub fn debug_observer_stats(&self) -> SnapshotStateObserverDebugStats
pub fn debug_last_pass_stats(&self) -> CompositionPassDebugStats
pub fn process_invalid_scopes(&mut self) -> Result<bool, NodeError>
Source§impl<A> Composition<A>where
A: Applier + 'static,
impl<A> Composition<A>where
A: Applier + 'static,
pub fn flush_pending_node_updates(&mut self) -> Result<(), NodeError>
Trait Implementations§
Source§impl<A> Drop for Composition<A>where
A: Applier + 'static,
impl<A> Drop for Composition<A>where
A: Applier + 'static,
Auto Trait Implementations§
impl<A> !RefUnwindSafe for Composition<A>
impl<A> !Send for Composition<A>
impl<A> !Sync for Composition<A>
impl<A> !UnwindSafe for Composition<A>
impl<A> Freeze for Composition<A>
impl<A> Unpin for Composition<A>
impl<A> UnsafeUnpin for Composition<A>
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.