pub trait Demo: Sized + 'static {
type Message: Any + Clone + Send + Debug;
// Required methods
fn boot() -> (Self, Task<Self::Message>);
fn update(&mut self, message: Self::Message) -> Task<Self::Message>;
fn view(&self) -> Element<'_, Self::Message>;
fn theme(&self) -> Theme;
fn set_theme(&mut self, theme: Theme);
// Provided method
fn subscription(&self) -> Subscription<Self::Message> { ... }
}Expand description
One demo application: the five methods iced::application takes, on a type.
The trait exists so the gallery can boot any demo through one signature.
Native main functions keep calling iced::application with the same
methods directly.
Required Associated Types§
Required Methods§
Sourcefn boot() -> (Self, Task<Self::Message>)
fn boot() -> (Self, Task<Self::Message>)
Builds the pristine scene the documentation shows.
Never loads persisted state: an embedded demo must look the same for every visitor, and the screenshot must match what the canvas renders.
fn update(&mut self, message: Self::Message) -> Task<Self::Message>
fn view(&self) -> Element<'_, Self::Message>
fn theme(&self) -> Theme
Provided Methods§
fn subscription(&self) -> Subscription<Self::Message>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".