pub trait Application: Sized + 'static {
type Message: Clone + 'static;
type Color: PixelColor;
type Screen: ScreenView<Self::Color, Self::Message>;
// Required methods
fn init() -> (Self, Task<Self::Message>);
fn update(&mut self, message: Self::Message) -> Task<Self::Message>;
fn view(&self) -> &Self::Screen;
// Provided method
fn subscription(&self) -> Subscription<Self::Message> { ... }
}Expand description
An application running under the Runtime.
libcosmic-shaped: the user defines an application type, not an
application value. The runtime calls Application::init to
obtain the initial state and a startup Task (used to kick off
async loads — read config, fetch initial data, etc.).
Required Associated Types§
Sourcetype Message: Clone + 'static
type Message: Clone + 'static
Application message type. Must be Clone for runtime
dispatch through update.
Sourcetype Color: PixelColor
type Color: PixelColor
Pixel color type used by this application’s display.
Sourcetype Screen: ScreenView<Self::Color, Self::Message>
type Screen: ScreenView<Self::Color, Self::Message>
Concrete screen type — typically a user-defined enum dispatching to per-screen structs via match arms.
Required Methods§
Sourcefn init() -> (Self, Task<Self::Message>)
fn init() -> (Self, Task<Self::Message>)
Construct the initial application state and a startup task. Called once by the runtime before the event loop starts.
Provided Methods§
Sourcefn subscription(&self) -> Subscription<Self::Message>
fn subscription(&self) -> Subscription<Self::Message>
Long-lived message sources. Called once at startup and after
every processed message — refresh is automatic. Identity comes
from the Recipe inside, so changing what’s returned
(or returning Subscription::none()) cleanly replaces the
subscription. Default: none.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".