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§
Required Methods§
Provided Methods§
Sourceasync fn start(&mut self, sender: &ComponentSender<Self>) -> !
async fn start(&mut self, sender: &ComponentSender<Self>) -> !
Start the event listening.
Sourceasync fn update(
&mut self,
message: Self::Message,
sender: &ComponentSender<Self>,
) -> Result<bool, Self::Error>
async fn update( &mut self, message: Self::Message, sender: &ComponentSender<Self>, ) -> Result<bool, Self::Error>
Respond to the message. Return true if need render.
Sourcefn render(&mut self, sender: &ComponentSender<Self>) -> Result<(), Self::Error>
fn render(&mut self, sender: &ComponentSender<Self>) -> Result<(), Self::Error>
Render the widgets.
Sourceasync fn update_children(&mut self) -> Result<bool, Self::Error>
async fn update_children(&mut self) -> Result<bool, Self::Error>
Update the children components. Return true if any child needs render.
Sourcefn render_children(&mut self) -> Result<(), Self::Error>
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.