Skip to main content

Demo

Trait Demo 

Source
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§

Source

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.

Source

fn update(&mut self, message: Self::Message) -> Task<Self::Message>

Source

fn view(&self) -> Element<'_, Self::Message>

Source

fn theme(&self) -> Theme

Source

fn set_theme(&mut self, theme: Theme)

Switches the demo onto theme, the way an embed follows the page theme of the site it sits in; the native binaries never call it.

Provided Methods§

Source

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".

Implementors§