Skip to main content

lgui_core/command/
mod.rs

1//! Typed, application-scoped commands.
2
3mod context;
4mod contract;
5mod handle;
6mod registry;
7
8pub use context::CommandContext;
9pub use contract::{Command, CommandFuture, CommandHandler};
10pub use handle::CommandHandle;
11pub(crate) use registry::CommandRegistry;
12
13/// Invokes a typed Command in the active Application.
14///
15/// LGUI async handlers and tasks automatically carry their Application scope.
16/// Futures submitted to an external executor must first be wrapped with
17/// `ApplicationContext::scope`.
18pub async fn invoke<C>(args: C::Args) -> Result<C::Output, C::Error>
19where
20    C: Command,
21{
22    let application = crate::application::current_application("invoke");
23    application.command::<C>().invoke(args).await
24}
25
26#[path = "command_test.rs"]
27#[cfg(test)]
28mod tests;