[][src]Trait iced_winit::Application

pub trait Application: Sized {
    type Renderer: Windowed;
    type Message: Debug + Send;
    fn new() -> (Self, Command<Self::Message>);
fn title(&self) -> String;
fn update(&mut self, message: Self::Message) -> Command<Self::Message>;
fn view(&mut self) -> Element<Self::Message, Self::Renderer>; fn run(settings: Settings)
    where
        Self: 'static
, { ... } }

An interactive, native cross-platform application.

This trait is the main entrypoint of Iced. Once implemented, you can run your GUI application by simply calling run. It will run in its own window.

An Application can execute asynchronous actions by returning a Command in some of its methods.

Associated Types

type Renderer: Windowed

The renderer to use to draw the Application.

type Message: Debug + Send

The type of messages your Application will produce.

Loading content...

Required methods

fn new() -> (Self, Command<Self::Message>)

Initializes the Application.

Here is where you should return the initial state of your app.

Additionally, you can return a Command if you need to perform some async action in the background on startup. This is useful if you want to load state from a file, perform an initial HTTP request, etc.

fn title(&self) -> String

Returns the current title of the Application.

This title can be dynamic! The runtime will automatically update the title of your application when necessary.

fn update(&mut self, message: Self::Message) -> Command<Self::Message>

Handles a message and updates the state of the Application.

This is where you define your update logic. All the messages, produced by either user interactions or commands, will be handled by this method.

Any Command returned will be executed immediately in the background.

fn view(&mut self) -> Element<Self::Message, Self::Renderer>

Returns the widgets to display in the Application.

These widgets can produce messages based on user interaction.

Loading content...

Provided methods

fn run(settings: Settings) where
    Self: 'static, 

Runs the Application.

This method will take control of the current thread and will NOT return.

It should probably be that last thing you call in your main function.

Loading content...

Implementors

Loading content...