Skip to main content

ComponentElement

Trait ComponentElement 

Source
pub trait ComponentElement: Element {
    // Required methods
    fn component_data(self: Handle<Self>, app: &App) -> &ComponentElementData;
    fn component_data_mut(
        self: Handle<Self>,
        app: &mut App,
    ) -> &mut ComponentElementData;
    fn build(self: Handle<Self>, app: &mut App) -> WidgetRef;

    // Provided methods
    fn build_tracked(self: Handle<Self>, app: &mut App) -> WidgetRef { ... }
    fn child(self: Handle<Self>, app: &App) -> Option<AnyElement> { ... }
    fn mount(
        self: Handle<Self>,
        app: &mut App,
        parent: Option<AnyElement>,
        new_slot: Option<Slot>,
    ) { ... }
    fn first_build(self: Handle<Self>, app: &mut App) { ... }
    fn perform_rebuild(self: Handle<Self>, app: &mut App) { ... }
    fn visit_children_component(
        self: Handle<Self>,
        app: &App,
        visitor: &mut dyn FnMut(AnyElement),
    ) { ... }
    fn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement) { ... }
}
Expand description

An Element that composes other Elements.

Rather than creating a RenderObject directly, a ComponentElement creates RenderObjects indirectly by creating other Elements.

Contrast with RenderObjectElement.

Required Methods§

Source

fn component_data(self: Handle<Self>, app: &App) -> &ComponentElementData

The child slot and build flag, held under the field component.

Source

fn component_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ComponentElementData

Source

fn build(self: Handle<Self>, app: &mut App) -> WidgetRef

Subclasses should override this function to actually call the appropriate build function (e.g., StatelessWidget::build or State::build) for their widget.

Provided Methods§

Source

fn build_tracked(self: Handle<Self>, app: &mut App) -> WidgetRef

Runs build inside App::entity_track and binds watches.

Source

fn child(self: Handle<Self>, app: &App) -> Option<AnyElement>

The child this element built, if any.

Source

fn mount( self: Handle<Self>, app: &mut App, parent: Option<AnyElement>, new_slot: Option<Slot>, )

ComponentElement.mount: the base mount, then the first build.

Source

fn first_build(self: Handle<Self>, app: &mut App)

ComponentElement._firstBuild.

Source

fn perform_rebuild(self: Handle<Self>, app: &mut App)

Calls the build method and then updates the widget tree.

Called automatically during ComponentElement::mount to generate the first build, and by rebuild when the element needs updating.

Source

fn visit_children_component( self: Handle<Self>, app: &App, visitor: &mut dyn FnMut(AnyElement), )

ComponentElement.visitChildren.

Source

fn forget_child(self: Handle<Self>, app: &mut App, child: AnyElement)

ComponentElement.forgetChild.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§