pub struct CliTransport {
bin: OnceLock<Result<PathBuf, TransportError>>,
bin_hint: Option<PathBuf>,
server_url: Option<String>,
stdout_dir: PathBuf,
call_timeout: Duration,
body_max_bytes: usize,
extra_env: Vec<(String, String)>,
removed_env: Vec<String>,
path: Option<String>,
user_home: PathBuf,
}Fields§
§bin: OnceLock<Result<PathBuf, TransportError>>§bin_hint: Option<PathBuf>§server_url: Option<String>§stdout_dir: PathBuf§call_timeout: Duration§body_max_bytes: usize§extra_env: Vec<(String, String)>§removed_env: Vec<String>§path: Option<String>§user_home: PathBufThe OS home: the third input of resolve_binary, kept because resolution is lazy.
Implementations§
Source§impl CliTransport
impl CliTransport
Sourcepub fn new(settings: &Settings, home: &Path, user_home: &Path) -> Self
pub fn new(settings: &Settings, home: &Path, user_home: &Path) -> Self
home is the ctl home (for the stdout directory), user_home the OS home.
Sourcepub fn with_extra_env(self, env: Vec<(String, String)>) -> Self
pub fn with_extra_env(self, env: Vec<(String, String)>) -> Self
Variables added to every child’s environment.
Sourcepub fn with_env_removed(self, names: Vec<String>) -> Self
pub fn with_env_removed(self, names: Vec<String>) -> Self
Variables removed from every child’s environment (applied after with_extra_env).
Sourcepub fn with_path(self, path: Option<String>) -> Self
pub fn with_path(self, path: Option<String>) -> Self
The PATH value resolve_binary searches; None = no PATH search.
Sourcepub fn stdout_dir(&self) -> &Path
pub fn stdout_dir(&self) -> &Path
This process’s stdout directory <home>/stdout/<pid>-<starttime> (created on first use).
fn bin(&self) -> Result<&Path, TransportError>
Source§impl CliTransport
impl CliTransport
fn ensure_stdout_dir(&self) -> Result<(), TransportError>
fn server_args(&self, args: &mut Vec<String>)
Sourceasync fn run(
&self,
args: &[String],
deadline: Duration,
) -> Result<Finished, TransportError>
async fn run( &self, args: &[String], deadline: Duration, ) -> Result<Finished, TransportError>
Spawn opencode <args> with stdout in a temp file, bounded by deadline.
Sourceasync fn probe(&self, carried: TransportError) -> TransportError
async fn probe(&self, carried: TransportError) -> TransportError
opencode service status once (deadline call_timeout): non-zero exit or stopped is
SERVICE_DOWN, otherwise the carried error.
Sourceasync fn fail(&self, mapped: Mapped) -> TransportError
async fn fail(&self, mapped: Mapped) -> TransportError
A failed run mapped, probed when the mapping asks for it and server_url is unset.
Trait Implementations§
Source§impl Transport for CliTransport
impl Transport for CliTransport
async fn call( &self, op: &Operation, params: &Params, body: Option<&Value>, deadline: Duration, ) -> Result<Value, TransportError>
async fn lifecycle(&self, v: Lifecycle) -> Result<String, TransportError>
async fn wait_idle( &self, session_id: &str, deadline: Duration, ) -> Result<WaitOutcome, TransportError>
async fn fetch_openapi(&self) -> Result<Value, TransportError>
Source§async fn cli_version(&self) -> Result<String, TransportError>
async fn cli_version(&self) -> Result<String, TransportError>
Raw
opencode --version stdout, trimmed, e.g. opencode v2.0.32.Auto Trait Implementations§
impl !Freeze for CliTransport
impl RefUnwindSafe for CliTransport
impl Send for CliTransport
impl Sync for CliTransport
impl Unpin for CliTransport
impl UnsafeUnpin for CliTransport
impl UnwindSafe for CliTransport
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