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§
Sourcetype Executor: Executor
type Executor: Executor
The Executor that will run commands and subscriptions.
The default executor can be a good starting point!
Sourcetype Message: Debug + Send
type Message: Debug + Send
The type of messages your MultiApplication will produce.
Sourcetype Flags
type Flags
The data needed to initialize your MultiApplication.
type Theme: Default + DefaultStyle
Required Methods§
Sourcefn new(flags: Self::Flags) -> (Self, Task<Self::Message>)
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.
Sourcefn namespace(&self) -> String
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.
Sourcefn update(&mut self, message: Self::Message) -> Task<Self::Message>
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.
Provided Methods§
Sourcefn theme(&self) -> Self::Theme
fn theme(&self) -> Self::Theme
Returns the current Theme of the window of the MultiApplication.
Sourcefn style(&self, theme: &Self::Theme) -> Appearance
fn style(&self, theme: &Self::Theme) -> Appearance
Returns the current Style of the Theme.
Sourcefn subscription(&self) -> Subscription<Self::Message>
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.
Sourcefn scale_factor(&self, window: Id) -> f64
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.
Sourcefn run(settings: Settings<Self::Flags>) -> Result<(), Error>
fn run(settings: Settings<Self::Flags>) -> Result<(), Error>
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.