Skip to main content

Component

Trait Component 

Source
pub trait Component: Sized {
    type Init<'a>;
    type Message;
    type Event;
    type Error: Debug;

    // Required method
    async fn init(
        init: Self::Init<'_>,
        sender: &ComponentSender<Self>,
    ) -> Result<Self, Self::Error>;

    // Provided methods
    async fn start(&mut self, sender: &ComponentSender<Self>) -> ! { ... }
    async fn update(
        &mut self,
        message: Self::Message,
        sender: &ComponentSender<Self>,
    ) -> Result<bool, Self::Error> { ... }
    fn render(
        &mut self,
        sender: &ComponentSender<Self>,
    ) -> Result<(), Self::Error> { ... }
    async fn update_children(&mut self) -> Result<bool, Self::Error> { ... }
    fn render_children(&mut self) -> Result<(), Self::Error> { ... }
}
Available on crate feature winio only.
Expand description

Foundamental GUI component.

Required Associated Types§

Source

type Init<'a>

Initial parameter type.

Source

type Message

The input message type to update.

Source

type Event

The output event type to the parent.

Source

type Error: Debug

The error type.

Required Methods§

Source

async fn init( init: Self::Init<'_>, sender: &ComponentSender<Self>, ) -> Result<Self, Self::Error>

Create the initial component.

Provided Methods§

Source

async fn start(&mut self, sender: &ComponentSender<Self>) -> !

Start the event listening.

Source

async fn update( &mut self, message: Self::Message, sender: &ComponentSender<Self>, ) -> Result<bool, Self::Error>

Respond to the message. Return true if need render.

Source

fn render(&mut self, sender: &ComponentSender<Self>) -> Result<(), Self::Error>

Render the widgets.

Source

async fn update_children(&mut self) -> Result<bool, Self::Error>

Update the children components. Return true if any child needs render.

Source

fn render_children(&mut self) -> Result<(), Self::Error>

Render the children components. It will be called if any child or self needs render.

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§

Source§

impl Component for Button

Source§

impl Component for Canvas

Source§

impl Component for CheckBox

Source§

impl Component for ComboBox

Source§

impl Component for Edit

Source§

impl Component for Label

Source§

impl Component for ListBox

Source§

impl Component for Progress

Source§

impl Component for RadioButton

Source§

impl Component for RadioButtonGroup

Source§

impl Component for ScrollBar

Source§

impl Component for ScrollView

Source§

impl Component for Slider

Source§

impl Component for TabView

Source§

impl Component for TabViewItem

Source§

impl Component for TextBox

Source§

impl Component for View

Source§

impl Component for Window

Source§

impl<M, Ev, Err> Component for BoxComponent<M, Ev, Err>
where Err: Debug,

Source§

type Error = Err

Source§

type Event = Ev

Source§

type Init<'a> = Infallible

Source§

type Message = M

Source§

impl<T> Component for ObservableVec<T>
where T: Clone,