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,
        identity: Option<&Identity>,
    ) -> impl Future<Output = Result<Self::Stream<T>, Self::Error>> + Send
       where R: CommandRequest + Send + Serialize,
             T: CommandResponse + Serialize + DeserializeOwned + Send + 'static;
    fn execute_one<R, T>(
        &self,
        request: R,
        identity: Option<&Identity>,
    ) -> impl Future<Output = Result<T, Self::Error>> + Send
       where R: CommandRequest + Send + Serialize,
             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 [Identity] 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, identity: Option<&Identity>, ) -> impl Future<Output = Result<Self::Stream<T>, Self::Error>> + Send

Source

fn execute_one<R, T>( &self, request: R, identity: Option<&Identity>, ) -> 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 Client

Available on crate feature cli-executor only.

POST /execute — the Client IS the executor: each command is one POST whose result streams back as SSE, run in-process by the daemon with the crate::identity::Identity headers applied as a per-request config override (a missing header DELETES that field for the run — the daemon never inherits its own resident value). The plugin_* trio is deliberately never stamped: plugin caller identity is unspoofable — only the daemon’s own plugins run may assert it. Dropping the returned stream aborts the request, which cancels the in-process run.

Source§

type Error = ExecuteError

Source§

type Stream<T> = Pin<Box<dyn Stream<Item = Result<T, ExecuteError>> + 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