pub trait Component {
// Required methods
fn render(&mut self, frame: &mut Frame<'_>, area: Rect) -> Result<()>;
fn handle_event(&mut self, event: Event) -> Result<ComponentAction>;
}Expand description
Trait for all UI components
Components are self-contained UI elements that:
- Manage their own state
- Handle their own events
- Render themselves
- Return actions for the app to handle
Required Methods§
Sourcefn render(&mut self, frame: &mut Frame<'_>, area: Rect) -> Result<()>
fn render(&mut self, frame: &mut Frame<'_>, area: Rect) -> Result<()>
Render the component to the given area
Sourcefn handle_event(&mut self, event: Event) -> Result<ComponentAction>
fn handle_event(&mut self, event: Event) -> Result<ComponentAction>
Handle an event (keyboard, mouse, etc.) Returns an action that the app should take
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".