Component

Trait Component 

Source
pub trait Component {
    // Required methods
    fn build(&self, context: AppContext) -> impl Widget + 'static;
    fn widget_id(&self) -> WidgetId;

    // Provided method
    fn compose(self) -> Composed<Self>
       where Self: Sized { ... }
}
Expand description

A trait for creating a Widget from simple functions.

Simplifies the creation of your own widgets.

Required Methods§

Source

fn build(&self, context: AppContext) -> impl Widget + 'static

Builds the inner widget.

Source

fn widget_id(&self) -> WidgetId

The id of this widget/component.

Provided Methods§

Source

fn compose(self) -> Composed<Self>
where Self: Sized,

Composes this component into a Widget using [ComposedWidget].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§