pub struct ReadOnlyTransport { /* private fields */ }Expand description
Read-only NDJSON transport wrapping a codex subprocess.
Each line read from stdout is a single JSON object. There is no stdin writing — the prompt is passed as a CLI argument.
Implementations§
Source§impl ReadOnlyTransport
impl ReadOnlyTransport
Sourcepub fn spawn(
cli_path: &str,
subcommand_parts: &[&str],
extra_args: &[String],
prompt: Option<&str>,
working_dir: Option<&Path>,
env_vars: &[(String, String)],
) -> Result<Self>
pub fn spawn( cli_path: &str, subcommand_parts: &[&str], extra_args: &[String], prompt: Option<&str>, working_dir: Option<&Path>, env_vars: &[(String, String)], ) -> Result<Self>
Spawn a new codex process.
The process is launched as
<cli_path> <subcommand_parts...> --json [extra_args...] [prompt].
Stdin is /dev/null — there is no send method.
§Errors
Returns SdkError::ProcessSpawn if the process cannot be started.
Sourcepub async fn recv(&mut self) -> Result<Option<Value>>
pub async fn recv(&mut self) -> Result<Option<Value>>
Read the next NDJSON line from stdout and parse it as a JSON value.
Returns Ok(None) when stdout reaches EOF (process exited).
§Errors
Returns SdkError::InvalidJson if a line is not valid JSON.
Returns SdkError::Io on read failure.
Sourcepub fn interrupt(&self) -> Result<()>
pub fn interrupt(&self) -> Result<()>
Send an interrupt signal (SIGINT on Unix) to the subprocess.
Sourcepub async fn wait_with_stderr(
&mut self,
) -> Result<(Option<i32>, Option<String>)>
pub async fn wait_with_stderr( &mut self, ) -> Result<(Option<i32>, Option<String>)>
Wait for the subprocess to exit and return the exit code and captured stderr.
Sourcepub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
Check whether the child process has exited without blocking.