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.

Implementations on Foreign Types§

Source§

impl<P> Program for Attach<P>
where P: Program + 'static, <P as Program>::Message: Debug + MaybeClone,

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 settings(&self) -> Settings

Source§

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

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, ) -> Option<<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) -> f32

Implementors§