Program

Trait Program 

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§

type State

The state of the program.

type Message: Send + 'static

The message of the program.

type Theme: 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 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>]

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.

Implementations on Foreign Types§

§

impl<P> Program for Attach<P>
where P: Program + 'static,

§

type State = Tester<P>

§

type Message = Message<P>

§

type Theme = Theme

§

type Renderer = <P as Program>::Renderer

§

type Executor = <P as Program>::Executor

§

fn name() -> &'static str

§

fn settings(&self) -> Settings

§

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

§

fn boot( &self, ) -> (<Attach<P> as Program>::State, Task<<Attach<P> as Program>::Message>)

§

fn update( &self, state: &mut <Attach<P> as Program>::State, message: <Attach<P> as Program>::Message, ) -> Task<<Attach<P> as Program>::Message>

§

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

§

fn theme( &self, state: &<Attach<P> as Program>::State, window: Id, ) -> Option<Theme>

Implementors§