pub trait CommandDispatcher: Send + Sync {
// Required methods
fn dispatch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
ctx: &'life2 mut ExecContext,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn eval_expr<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
expr: &'life1 Expr,
ctx: &'life2 ExecContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn fork<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<dyn CommandDispatcher>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn fork_attached<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<dyn CommandDispatcher>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for dispatching a single command through the full resolution chain.
Implementations handle argument parsing, tool lookup, and execution. The pipeline runner handles I/O routing (stdin, redirects, piping).
Required Methods§
Sourcefn dispatch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
ctx: &'life2 mut ExecContext,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn dispatch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
ctx: &'life2 mut ExecContext,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Dispatch a single command for execution.
The ctx provides stdin (from pipe or redirect), scope, and backend.
Implementations should handle schema-aware argument parsing and
output format extraction internally.
Sourcefn eval_expr<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
expr: &'life1 Expr,
ctx: &'life2 ExecContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn eval_expr<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
expr: &'life1 Expr,
ctx: &'life2 ExecContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Evaluate an expression through the full async chain.
Unlike the runner’s sync eval_simple_expr, this can run command
substitution ($(...)) because it has access to pipeline execution.
Used for redirect targets and heredoc bodies so cat < $(cmd),
echo x > $(cmd), and $(...) inside heredoc bodies work. The ctx
carries scope/cwd/backend for dispatchers that evaluate against it;
stateful dispatchers (Kernel) snapshot their own session state and
only let command output escape (side effects like cd do not).
Sourcefn fork<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<dyn CommandDispatcher>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fork<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<dyn CommandDispatcher>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fork the dispatcher for concurrent execution (detached).
Returns a subsidiary dispatcher with independent mutable state, safe
to run concurrently with the parent and other forks without data
races on shared scope/cwd/aliases. Used by background & jobs,
where the fork must survive parent cancellation.
For stateful dispatchers (e.g. Kernel) this snapshots per-session state into a fresh instance. Stateless dispatchers may clone.
Provided Methods§
Sourcefn fork_attached<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<dyn CommandDispatcher>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fork_attached<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Arc<dyn CommandDispatcher>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fork the dispatcher for concurrent execution (attached to parent cancel).
Like Self::fork but the fork’s cancellation token is a child of
the parent’s. Cancelling the parent (timeout, Ctrl-C, embedder
Kernel::cancel) cascades into the fork, which then kills its own
external children via the usual SIGTERM/SIGKILL discipline.
Used for foreground concurrency: scatter workers, concurrent pipeline
stages, command substitution. Default implementation delegates to
Self::fork for stateless dispatchers that don’t track cancellation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".