pub trait Application<M = Infallible> {
// Required methods
fn update(&mut self, signal: Signal<M>) -> UpdateResult;
fn view(&self, frame: u64) -> ScopedElement<'_>;
}Expand description
A data-driven terminal application: what Runner::run drives.
AsyncApplication is the same seam for a host whose update awaits;
the split exists because only the runtime differs, not the contract.
The runner mutably borrows the application only while delivering a
Signal, then immutably borrows it to build the next frame. Because the
returned tree is scoped to that immutable borrow, custom views can read
application data directly without cloning it into an owned Element or
sharing it through Rc<RefCell<_>>.
Rendering should be pure: persistent UI and domain state belongs on the
application and changes only in update.
Required Methods§
Sourcefn update(&mut self, signal: Signal<M>) -> UpdateResult
fn update(&mut self, signal: Signal<M>) -> UpdateResult
Update application state in response to a tick, terminal event, or
message. Return UpdateResult::Clean only when the signal was
unhandled, or UpdateResult::Consumed when it was handled without a
repaint.
Sourcefn view(&self, frame: u64) -> ScopedElement<'_>
fn view(&self, frame: u64) -> ScopedElement<'_>
Build the ephemeral view tree for one numbered frame.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".