pub trait AppState<Global, Event, Error>{
// Provided methods
fn init(
&mut self,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<(), Error> { ... }
fn shutdown(
&mut self,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<(), Error> { ... }
fn event(
&mut self,
event: &Event,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<Control<Event>, Error> { ... }
fn error(
&self,
event: Error,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<Control<Event>, Error> { ... }
}Expand description
AppState executes events and has some init and error-handling.
There is no separate shutdown, handle this case with an application specific event.
Provided Methods§
Sourcefn init(
&mut self,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<(), Error>
fn init( &mut self, ctx: &mut AppContext<'_, Global, Event, Error>, ) -> Result<(), Error>
Initialize the application. Runs before the first repaint.
Sourcefn shutdown(
&mut self,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<(), Error>
fn shutdown( &mut self, ctx: &mut AppContext<'_, Global, Event, Error>, ) -> Result<(), Error>
Shutdown the application. Runs after the event-loop has ended.
Panic
Doesn’t run if a panic occurred.
Errors Any errors will be returned to main().
Sourcefn event(
&mut self,
event: &Event,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<Control<Event>, Error>
fn event( &mut self, event: &Event, ctx: &mut AppContext<'_, Global, Event, Error>, ) -> Result<Control<Event>, Error>
Handle an event.
Sourcefn error(
&self,
event: Error,
ctx: &mut AppContext<'_, Global, Event, Error>,
) -> Result<Control<Event>, Error>
fn error( &self, event: Error, ctx: &mut AppContext<'_, Global, Event, Error>, ) -> Result<Control<Event>, Error>
Do error handling.