Skip to main content

CommandExecutor

Trait CommandExecutor 

Source
pub trait CommandExecutor {
    type Error: Send + 'static;
    type Stream<T>: Stream<Item = Result<T, Self::Error>> + Send + 'static
       where T: Send + 'static;

    // Required methods
    fn execute<R, T>(
        &self,
        request: R,
        agent_arguments: Option<&AgentArguments>,
    ) -> impl Future<Output = Result<Self::Stream<T>, Self::Error>> + Send
       where R: CommandRequest + Send,
             T: CommandResponse + Serialize + DeserializeOwned + Send + 'static;
    fn execute_one<R, T>(
        &self,
        request: R,
        agent_arguments: Option<&AgentArguments>,
    ) -> impl Future<Output = Result<T, Self::Error>> + Send
       where R: CommandRequest + Send,
             T: CommandResponse + Serialize + DeserializeOwned + Send + 'static;
}
Expand description

Run a CommandRequest against some backend (subprocess of the cli binary, in-process router, mock, …) and surface its output as a stream of typed items.

T is left to the caller: pick a concrete leaf response type (agents::spawn::Response, functions::execute::standard::ResponseItem, …) or a more general serde_json::Value for opaque consumption.

Every call accepts an optional [AgentArguments] bag controlling per-call identity. When Some, subprocess-spawning executors stamp each Some(v) field on the child env and env_remove each None — atomic per-call override. When None, the child inherits parent env unchanged. In-process executors (e.g. the plugin executor) accept the parameter for trait-signature symmetry and ignore it.

Required Associated Types§

Source

type Error: Send + 'static

Source

type Stream<T>: Stream<Item = Result<T, Self::Error>> + Send + 'static where T: Send + 'static

Required Methods§

Source

fn execute<R, T>( &self, request: R, agent_arguments: Option<&AgentArguments>, ) -> impl Future<Output = Result<Self::Stream<T>, Self::Error>> + Send

Source

fn execute_one<R, T>( &self, request: R, agent_arguments: Option<&AgentArguments>, ) -> impl Future<Output = Result<T, Self::Error>> + Send

Convenience for unary commands: run the request and resolve the first item from the stream. Implementations should error with their own “empty stream” variant if the stream closes without producing an item.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CommandExecutor for BinaryExecutor

Source§

type Error = Error

Source§

type Stream<T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + Send>> where T: Send + 'static

Source§

impl CommandExecutor for PluginExecutor

Source§

type Error = Error

Source§

type Stream<T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + Send>> where T: Send + 'static