Struct ComponentTree

Source
pub struct ComponentTree { /* private fields */ }
Expand description

Manager for the component tree

Handles parent-child relationships, lifecycle coordination, and efficient updates

Implementations§

Source§

impl ComponentTree

Source

pub fn new(context: Context) -> Self

Create a new component tree

Source

pub fn set_root(&self, component_id: ComponentId) -> TreeResult<()>

Set the root component

Source

pub fn root_id(&self) -> TreeResult<Option<ComponentId>>

Get the root component ID

Source

pub fn add_component( &self, component: ComponentInstance, ) -> TreeResult<ComponentId>

Add a component to the tree

Source

pub fn remove_component(&self, id: ComponentId) -> TreeResult<()>

Remove a component from the tree

Source

pub fn add_child( &self, parent_id: ComponentId, child_id: ComponentId, ) -> TreeResult<()>

Add a child component to a parent

Source

pub fn remove_child( &self, parent_id: ComponentId, child_id: ComponentId, ) -> TreeResult<()>

Remove a child from a parent

Source

pub fn get_component( &self, id: ComponentId, ) -> TreeResult<Arc<RwLock<ComponentInstance>>>

Get a component instance by ID

Source

pub fn get_lifecycle_manager( &self, id: ComponentId, ) -> TreeResult<Arc<RwLock<LifecycleManager>>>

Get a lifecycle manager by component ID

Source

pub fn initialize_component(&self, id: ComponentId) -> TreeResult<()>

Initialize a component

Source

pub fn mount_component(&self, id: ComponentId) -> TreeResult<()>

Mount a component

Source

pub fn unmount_component(&self, id: ComponentId) -> TreeResult<()>

Unmount a component

Source

pub fn render_component(&self, id: ComponentId) -> TreeResult<Vec<Node>>

Render a component

Source

pub fn has_component(&self, id: ComponentId) -> bool

Check if a component exists in the tree

Source

pub fn get_children(&self, id: ComponentId) -> TreeResult<Vec<ComponentId>>

Get the children of a component

Source

pub fn get_parent(&self, id: ComponentId) -> TreeResult<Option<ComponentId>>

Get the parent of a component

Source

pub fn mount_component_tree(&self, id: ComponentId) -> TreeResult<()>

Recursively mount a component and all its children

Source

pub fn unmount_component_tree(&self, id: ComponentId) -> TreeResult<()>

Recursively unmount a component and all its children

Source

pub fn update_component<P: Props + 'static>( &self, id: ComponentId, props: P, ) -> TreeResult<()>

Update a component with new props

Source

pub fn update_component_tree<P: Props + Clone + 'static>( &self, id: ComponentId, props: P, ) -> TreeResult<()>

Recursively update a component and its children if needed

Source

pub fn get_all_components(&self) -> TreeResult<Vec<ComponentId>>

Get all components in the tree

Source

pub fn get_components_to_update(&self) -> TreeResult<Vec<ComponentId>>

Get all components that need updating

Source

pub fn detect_state_changes(&self, id: ComponentId) -> TreeResult<bool>

Perform state change detection for a component

Source

pub fn batch_update_components(&self, ids: &[ComponentId]) -> TreeResult<usize>

Batch update multiple components

Trait Implementations§

Source§

impl Debug for ComponentTree

Source§

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

Formats the value using the given formatter. 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> 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, 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.