Skip to main content

CommandExecutor

Trait CommandExecutor 

Source
pub trait CommandExecutor: Send + Sync {
    // Required method
    fn get_handle(&self, id: &CommandId) -> Option<Arc<dyn CommandHandle>>;
}
Expand description

Trait for command handler lookup.

Runner’s CommandRegistry implements this trait. This abstraction prevents session driver from depending on runner types.

§Design

Instead of SessionRuntime holding a concrete CommandRegistry, it holds &dyn CommandExecutor. This maintains proper dependency direction: runner depends on session driver, not vice versa.

§Re-Entrant Execution (#547)

get_handle() returns an owned Arc<dyn CommandHandle>, releasing the borrow on the executor. The caller then invokes handle.execute(runtime, ctx) with full &mut SessionRuntime access.

Required Methods§

Source

fn get_handle(&self, id: &CommandId) -> Option<Arc<dyn CommandHandle>>

Look up a command handler by ID.

Returns an Arc so the caller can execute the handler through its own runtime (re-entrant execution). Returns None if the command is not found.

Implementors§