Program

Trait Program 

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

    // Required methods
    fn name() -> &'static str;
    fn settings(&self) -> Settings;
    fn window(&self) -> Option<Settings>;
    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) -> Option<Self::Theme> { ... }
    fn style(&self, _state: &Self::State, theme: &Self::Theme) -> Style { ... }
    fn scale_factor(&self, _state: &Self::State, _window: Id) -> f32 { ... }
    fn presets(&self) -> &[Preset<Self::State, Self::Message>] { ... }
}
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§

Source

type State

The state of the program.

Source

type Message: Send + 'static

The message of the program.

Source

type Theme: Base

The theme of the program.

Source

type Renderer: Renderer

The renderer of the program.

Source

type Executor: Executor

The executor of the program.

Required Methods§

Source

fn name() -> &'static str

Returns the unique name of the Program.

Source

fn settings(&self) -> Settings

Source

fn window(&self) -> Option<Settings>

Source

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

Source

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

Source

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

Provided Methods§

Source

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

Source

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

Source

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

Source

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

Source

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

Source

fn presets(&self) -> &[Preset<Self::State, Self::Message>]

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§