pub trait App {
type AppMessage;
// Required methods
fn draw(&mut self, frame: &mut Frame<'_>);
fn handle_event(&self, event: Event) -> Option<Message<Self::AppMessage>>;
fn handle_message(
&mut self,
message: Self::AppMessage
) -> Option<impl Future<Output = Message<Self::AppMessage>> + Send + 'static>;
}
Expand description
Application behavior.
Required Associated Types§
type AppMessage
Required Methods§
sourcefn draw(&mut self, frame: &mut Frame<'_>)
fn draw(&mut self, frame: &mut Frame<'_>)
After every message, this function is called to draw the UI.
As Ratatui is an immediate mode library, this very simply renders the whole UI on each call.
The state is expected to be stored in the App
implementation.
sourcefn handle_event(&self, event: Event) -> Option<Message<Self::AppMessage>>
fn handle_event(&self, event: Event) -> Option<Message<Self::AppMessage>>
Handle events.
This function is called for every event. It maps the event to an (optional) message which may be handled by the application.
sourcefn handle_message(
&mut self,
message: Self::AppMessage
) -> Option<impl Future<Output = Message<Self::AppMessage>> + Send + 'static>
fn handle_message( &mut self, message: Self::AppMessage ) -> Option<impl Future<Output = Message<Self::AppMessage>> + Send + 'static>
Handle messages.
This function is called for every message. It may modify the state of the application, and (optionally) returns a future which will return a message in the future.
Object Safety§
This trait is not object safe.