// Copyright 2023 System76 // SPDX-License-Identifier: MPL-2.0 use std::future::Future; use super::{Command, Message}; use iced_runtime::command::Action; /// Yields a command which contains a batch of commands. pub fn batch(commands: impl IntoIterator>) -> Command { Command::batch(commands) } /// Yields a command which will run the future on the runtime executor. pub fn future( future: impl Future> + Send + 'static, ) -> Command { Command::single(Action::Future(Box::pin(future))) } /// Creates a command which yields a [`crate::app::Message`]. pub fn message(message: Message) -> Command { crate::command::message(message) } /// Convenience methods for building message-based commands. pub mod message { /// Creates a command which yields an application message. pub fn app(message: M) -> crate::app::Command { super::message(super::Message::App(message)) } /// Creates a command which yields a cosmic message. pub fn cosmic( message: crate::app::cosmic::Message, ) -> crate::app::Command { super::message(super::Message::Cosmic(message)) } } pub fn drag() -> iced::Command> { crate::command::drag().map(Message::Cosmic) } pub fn fullscreen() -> iced::Command> { crate::command::fullscreen().map(Message::Cosmic) } pub fn minimize() -> iced::Command> { crate::command::minimize().map(Message::Cosmic) } pub fn set_title(title: String) -> iced::Command> { crate::command::set_title(title).map(Message::Cosmic) } pub fn set_windowed() -> iced::Command> { crate::command::set_windowed().map(Message::Cosmic) } pub fn toggle_fullscreen() -> iced::Command> { crate::command::toggle_fullscreen().map(Message::Cosmic) }