pub trait Component {
// Required method
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()>;
// Provided methods
fn register_action_handler(
&mut self,
tx: UnboundedSender<Action>,
) -> Result<()> { ... }
fn register_config_handler(&mut self, config: Config) -> Result<()> { ... }
fn init(&mut self, _area: Rect) -> Result<()> { ... }
fn handle_events(&mut self, event: Option<Event>) -> Result<Vec<Action>> { ... }
fn handle_key_events(&mut self, key: KeyEvent) -> Result<Vec<Action>> { ... }
fn handle_mouse_events(&mut self, mouse: MouseEvent) -> Result<Vec<Action>> { ... }
fn update(&mut self, action: Action) -> Result<Option<Action>> { ... }
}Expand description
Component is a trait that represents a visual and interactive element of the user interface.
Implementors of this trait can be registered with the main application loop and will be able to receive events,
update state, and be rendered on the screen.
Required Methods§
Provided Methods§
Sourcefn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()>
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()>
Sourcefn register_config_handler(&mut self, config: Config) -> Result<()>
fn register_config_handler(&mut self, config: Config) -> Result<()>
Sourcefn handle_mouse_events(&mut self, mouse: MouseEvent) -> Result<Vec<Action>>
fn handle_mouse_events(&mut self, mouse: MouseEvent) -> Result<Vec<Action>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".