Trait Program

pub trait Program: Sized {
    type State;
    type Message: Send + Debug + 'static;
    type Theme: Default + Base;
    type Renderer: Renderer;
    type Executor: Executor;

    // Required methods
    fn name() -> &'static str;
    fn boot(&self) -> (Self::State, Task<Self::Message>);
    fn update(
        &self,
        state: &mut Self::State,
        message: Self::Message,
    ) -> Task<Self::Message>;
    fn view<'a>(
        &self,
        state: &'a Self::State,
        window: Id,
    ) -> Element<'a, Self::Message, Self::Theme, Self::Renderer>;

    // Provided methods
    fn title(&self, _state: &Self::State, _window: Id) -> String { ... }
    fn subscription(&self, _state: &Self::State) -> Subscription<Self::Message> { ... }
    fn theme(&self, _state: &Self::State, _window: Id) -> Self::Theme { ... }
    fn style(&self, _state: &Self::State, theme: &Self::Theme) -> Style { ... }
    fn scale_factor(&self, _state: &Self::State, _window: Id) -> f64 { ... }
}
Expand description

An interactive, native, cross-platform, multi-windowed application.

A Program can execute asynchronous actions by returning a Task in some of its methods.

Required Associated Types§

type State

The state of the program.

type Message: Send + Debug + 'static

The message of the program.

type Theme: Default + Base

The theme of the program.

type Renderer: Renderer

The renderer of the program.

type Executor: Executor

The executor of the program.

Required Methods§

fn name() -> &'static str

Returns the unique name of the Program.

fn boot(&self) -> (Self::State, Task<Self::Message>)

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

fn view<'a>( &self, state: &'a Self::State, window: Id, ) -> Element<'a, Self::Message, Self::Theme, Self::Renderer>

Provided Methods§

fn title(&self, _state: &Self::State, _window: Id) -> String

fn subscription(&self, _state: &Self::State) -> Subscription<Self::Message>

fn theme(&self, _state: &Self::State, _window: Id) -> Self::Theme

fn style(&self, _state: &Self::State, theme: &Self::Theme) -> Style

fn scale_factor(&self, _state: &Self::State, _window: Id) -> f64

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§