Common/Command/GetAllCommands.rs
1// File: Common/Source/Command/GetAllCommands.rs
2// Role: Defines the `GetAllCommands` ActionEffect.
3// Responsibilities:
4// - Provide a declarative effect for retrieving a list of all registered
5// command identifiers.
6// - This effect abstracts the "what" (get all commands) from the "how" (the
7// CommandExecutor implementation).
8
9use std::sync::Arc;
10
11use super::CommandExecutor::CommandExecutor;
12use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
13
14/// Creates an effect that, when executed, will retrieve a list of all currently
15/// registered command identifiers.
16///
17/// This includes both native commands implemented in Rust and proxied commands
18/// contributed by external sidecars. It uses the `CommandExecutor` capability
19/// from the environment to perform the operation.
20///
21/// # Returns
22///
23/// An `ActionEffect` that resolves with a `Vec<String>` of command
24/// identifiers. The capability required to run this effect is an
25/// `Arc<dyn CommandExecutor>`.
26pub fn GetAllCommands() -> ActionEffect<Arc<dyn CommandExecutor>, CommonError, Vec<String>> {
27 ActionEffect::New(Arc::new(move |Executor:Arc<dyn CommandExecutor>| {
28 Box::pin(async move { Executor.GetAllCommands().await })
29 }))
30}