pub struct BinaryExecutor { /* private fields */ }Expand description
Spawn the objectiveai cli binary on disk, feed it the argv from
request.into_command(), and stream each stdout JSONL line back as
either a typed T or a structured crate::cli::Error.
The binary is resolved at execute time (not at construction).
Resolution order:
BinaryExecutor::from_path— returns the explicit path verbatim (used by tests pointing at an out-of-tree build).BinaryExecutor::newwithSome(objectiveai_dir)—<objectiveai_dir>/bin/objectiveai{.exe}.BinaryExecutor::newwithNone—<home>/.objectiveai/bin/objectiveai{.exe}.
Implementations§
Source§impl BinaryExecutor
impl BinaryExecutor
pub fn new(objectiveai_dir: Option<impl Into<PathBuf>>) -> Self
Sourcepub fn from_path(binary: impl Into<PathBuf>) -> Self
pub fn from_path(binary: impl Into<PathBuf>) -> Self
Construct an executor that spawns the binary at binary
directly, regardless of file name. Skips the objectiveai
name lookup so tests can target a target/debug/objectiveai-cli
build without renaming or symlinking.
Sourcepub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set an environment variable on every child the executor spawns.
Stacks on top of the parent’s env; intended for tests that need
to pin a per-instance OBJECTIVEAI_DIR/OBJECTIVEAI_STATE or OBJECTIVEAI_ADDRESS
without racing other parallel tests via std::env::set_var.
Sourcepub fn kill_on_drop(self, on: bool) -> Self
pub fn kill_on_drop(self, on: bool) -> Self
When true, the spawned tokio::process::Child held in the
stream state is sent a kill signal when the stream is dropped.
Defaults to false. Wrappers that detect hangs (e.g. the
cli-test HangPreventingBinaryCommandExecutor) toggle this on
so dropping the inner stream tears the cli child down.
Sourcepub fn detach(self, on: bool) -> Self
pub fn detach(self, on: bool) -> Self
When true, the child is spawned detached from the parent’s
console / process group so it survives parent exit. Pairs
naturally with kill_on_drop = false (the default): drop the
stream + exit the parent, the child keeps running orphaned.
- Windows: sets
DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUPon theCreateProcessWcall.DETACHED_PROCESSis what actually makes orphan survival work — without it the child inherits the parent’s console and receivesCTRL_CLOSE_EVENTwhen the parent’s console window closes. The process-group flag is belt-and-suspenders signal isolation. - Unix: no-op. The kernel automatically re-parents the child to init when the parent exits.
Defaults to false.
Trait Implementations§
Source§impl CommandExecutor for BinaryExecutor
impl CommandExecutor for BinaryExecutor
type Error = Error
type Stream<T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + Send>> where T: Send + 'static
async fn execute<R, T>( &self, request: R, agent_arguments: Option<&AgentArguments>, ) -> Result<Self::Stream<T>, Error>
Source§async fn execute_one<R, T>(
&self,
request: R,
agent_arguments: Option<&AgentArguments>,
) -> Result<T, Error>
async fn execute_one<R, T>( &self, request: R, agent_arguments: Option<&AgentArguments>, ) -> Result<T, Error>
Auto Trait Implementations§
impl Freeze for BinaryExecutor
impl RefUnwindSafe for BinaryExecutor
impl Send for BinaryExecutor
impl Sync for BinaryExecutor
impl Unpin for BinaryExecutor
impl UnsafeUnpin for BinaryExecutor
impl UnwindSafe for BinaryExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more