iced_sessionlock

Trait MultiApplication

Source
pub trait MultiApplication: Sized {
    type Executor: Executor;
    type Message: Debug + Send;
    type Flags;
    type Theme: Default + DefaultStyle;

    // Required methods
    fn new(flags: Self::Flags) -> (Self, Task<Self::Message>);
    fn namespace(&self) -> String;
    fn update(&mut self, message: Self::Message) -> Task<Self::Message>;
    fn view(
        &self,
        window: Id,
    ) -> Element<'_, Self::Message, Self::Theme, Renderer>;

    // Provided methods
    fn theme(&self) -> Self::Theme { ... }
    fn style(&self, theme: &Self::Theme) -> Appearance { ... }
    fn subscription(&self) -> Subscription<Self::Message> { ... }
    fn scale_factor(&self, window: Id) -> f64 { ... }
    fn run(settings: Settings<Self::Flags>) -> Result<(), Error>
       where Self: 'static,
             Self::Message: 'static + TryInto<UnLockAction, Error = Self::Message> { ... }
}

Required Associated Types§

Source

type Executor: Executor

The Executor that will run commands and subscriptions.

The default executor can be a good starting point!

Source

type Message: Debug + Send

The type of messages your MultiApplication will produce.

Source

type Flags

The data needed to initialize your MultiApplication.

Source

type Theme: Default + DefaultStyle

Required Methods§

Source

fn new(flags: Self::Flags) -> (Self, Task<Self::Message>)

Initializes the MultiApplication with the flags provided to run as part of the Settings.

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

Additionally, you can return a Task 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.

Source

fn namespace(&self) -> String

Returns the current title of the window of the MultiApplication.

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

Source

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

Handles a message and updates the state of the MultiApplication.

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 Task returned will be executed immediately in the background.

Source

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

Returns the widgets to display in the window of the MultiApplication.

These widgets can produce messages based on user interaction.

Provided Methods§

Source

fn theme(&self) -> Self::Theme

Returns the current Theme of the window of the MultiApplication.

Source

fn style(&self, theme: &Self::Theme) -> Appearance

Returns the current Style of the Theme.

Source

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

Returns the event Subscription for the current state of the application.

A Subscription will be kept alive as long as you keep returning it, and the messages produced will be handled by update.

By default, this method returns an empty Subscription.

Source

fn scale_factor(&self, window: Id) -> f64

Returns the scale factor of the window of the MultiApplication.

It can be used to dynamically control the size of the UI at runtime (i.e. zooming).

For instance, a scale factor of 2.0 will make widgets twice as big, while a scale factor of 0.5 will shrink them to half their size.

By default, it returns 1.0.

Source

fn run(settings: Settings<Self::Flags>) -> Result<(), Error>
where Self: 'static, Self::Message: 'static + TryInto<UnLockAction, Error = Self::Message>,

Runs the multi-window MultiApplication.

On native platforms, this method will take control of the current thread until the MultiApplication exits.

On the web platform, this method will NOT return unless there is an Error during startup.

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§