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(config_base_dir)—<config_base_dir>/objectiveai{.exe}.BinaryExecutor::newwithNone—<home>/.objectiveai/objectiveai{.exe}.
Implementations§
Source§impl BinaryExecutor
impl BinaryExecutor
pub fn new(config_base_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 CONFIG_BASE_DIR or OBJECTIVEAI_ADDRESS
without racing other parallel tests via std::env::set_var.
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>
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.
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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