Skip to main content

App

Trait App 

Source
pub trait App: 'static {
    // Required method
    fn build(
        &mut self,
        ui: &mut Ui,
        host: &mut Host<'_>,
    ) -> Result<(), Box<dyn Error>>;

    // Provided methods
    fn action(&mut self, ui: &mut Ui, host: &mut Host<'_>, action: Action) { ... }
    fn frame(&mut self, ui: &mut Ui, host: &mut Host<'_>) -> bool { ... }
}
Expand description

An application: it builds its interface once, then reacts to what widgets report and updates live content before each frame. Every call gets the Host: the window it runs in.

Required Methods§

Source

fn build( &mut self, ui: &mut Ui, host: &mut Host<'_>, ) -> Result<(), Box<dyn Error>>

Fills the interface: called once, when the window and its Ui exist.

§Errors

Any error stops run, which returns it.

Provided Methods§

Source

fn action(&mut self, ui: &mut Ui, host: &mut Host<'_>, action: Action)

Handles an action a widget reported (a click, an edit), right after the input that caused it.

Source

fn frame(&mut self, ui: &mut Ui, host: &mut Host<'_>) -> bool

Updates live content before a frame is painted. Return true to keep painting frames continuously (animation), false to paint only when something changes or a Waker asks for a frame.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§