pub trait PluginComponent: Send {
// Required methods
fn handle(
&mut self,
event: &ComponentEvent,
context: &ComponentContext<'_>,
) -> ComponentFlow;
fn render(&self, context: &ComponentContext<'_>) -> ComponentView;
// Provided methods
fn bindings(&self) -> Vec<ComponentBinding> { ... }
fn focusable(&self) -> bool { ... }
fn tick(&self) -> Option<Duration> { ... }
fn mouse(&self) -> bool { ... }
}Expand description
An interactive component: a state machine that handles one event at a
time and renders its state. Registered with
PluginRegistrar::component
through a ComponentFactory.
Key presses and pastes come as text from the user, and so does anything a component shows of them: treat them as untrusted. The host keeps terminal controls out of what is painted.
Required Methods§
Sourcefn handle(
&mut self,
event: &ComponentEvent,
context: &ComponentContext<'_>,
) -> ComponentFlow
fn handle( &mut self, event: &ComponentEvent, context: &ComponentContext<'_>, ) -> ComponentFlow
Handle one event. Ctrl+C never arrives: the host ends the run.
Sourcefn render(&self, context: &ComponentContext<'_>) -> ComponentView
fn render(&self, context: &ComponentContext<'_>) -> ComponentView
Render the current state.
Provided Methods§
Sourcefn bindings(&self) -> Vec<ComponentBinding>
fn bindings(&self) -> Vec<ComponentBinding>
The keys it uses now, for help and hints. None, by default.
Sourcefn focusable(&self) -> bool
fn focusable(&self) -> bool
Whether it takes focus in a container. Yes, by default; a view that only shows something says no.
Sourcefn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
How often it wants ComponentEvent::Tick. Never, by default.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".