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 file_drop(&mut self, ui: &mut Ui, host: &mut Host<'_>, drop: FileDrop) { ... }
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§
Sourcefn build(
&mut self,
ui: &mut Ui,
host: &mut Host<'_>,
) -> Result<(), Box<dyn Error>>
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.
Start threads that bring data here, giving each a Waker (host.waker()): they
send what they read (over a channel, say) and call Waker::wake;
frame takes it in. The densa crate’s front page and densa-widgets’
monitor example show the whole pattern.
§Errors
Any error stops run, which returns it.
Provided Methods§
Sourcefn action(&mut self, ui: &mut Ui, host: &mut Host<'_>, action: Action)
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.
Sourcefn file_drop(&mut self, ui: &mut Ui, host: &mut Host<'_>, drop: FileDrop)
fn file_drop(&mut self, ui: &mut Ui, host: &mut Host<'_>, drop: FileDrop)
Handles a file dragged over the window or dropped on it (one call per file). Nothing happens unless the app does something with it.
Sourcefn frame(&mut self, ui: &mut Ui, host: &mut Host<'_>) -> bool
fn frame(&mut self, ui: &mut Ui, host: &mut Host<'_>) -> bool
Updates live content before a frame is painted: take in what your threads sent, and
change widgets through ui.update. Return true to keep painting frames
continuously (animation), false to paint only when something changes or a
Waker asks for a frame. Data that arrives from threads needs false: their
wakes bring the frames.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".