Trait Program

pub trait Program: Sized {
    type State;
    type Message: Message + '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: Message + '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.

Implementations on Foreign Types§

Source§

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

Source§

type State = DevTools<P>

Source§

type Message = Event<P>

Source§

type Theme = <P as Program>::Theme

Source§

type Renderer = <P as Program>::Renderer

Source§

type Executor = <P as Program>::Executor

Source§

fn name() -> &'static str

Source§

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

Source§

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

Source§

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>

Source§

fn title(&self, state: &<Attach<P> as Program>::State, window: Id) -> String

Source§

fn subscription( &self, state: &<Attach<P> as Program>::State, ) -> Subscription<<Attach<P> as Program>::Message>

Source§

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

Source§

fn style( &self, state: &<Attach<P> as Program>::State, theme: &<Attach<P> as Program>::Theme, ) -> Style

Source§

fn scale_factor(&self, state: &<Attach<P> as Program>::State, window: Id) -> f64

Implementors§