Skip to main content

CliTransport

Struct CliTransport 

Source
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: PathBuf

The OS home: the third input of resolve_binary, kept because resolution is lazy.

Implementations§

Source§

impl CliTransport

Source

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.

Source

pub fn with_extra_env(self, env: Vec<(String, String)>) -> Self

Variables added to every child’s environment.

Source

pub fn with_env_removed(self, names: Vec<String>) -> Self

Variables removed from every child’s environment (applied after with_extra_env).

Source

pub fn with_path(self, path: Option<String>) -> Self

The PATH value resolve_binary searches; None = no PATH search.

Source

pub fn stdout_dir(&self) -> &Path

This process’s stdout directory <home>/stdout/<pid>-<starttime> (created on first use).

Source

fn bin(&self) -> Result<&Path, TransportError>

Source§

impl CliTransport

Source

fn ensure_stdout_dir(&self) -> Result<(), TransportError>

Source

fn server_args(&self, args: &mut Vec<String>)

Source

async fn run( &self, args: &[String], deadline: Duration, ) -> Result<Finished, TransportError>

Spawn opencode <args> with stdout in a temp file, bounded by deadline.

Source

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.

Source

async fn fail(&self, mapped: Mapped) -> TransportError

A failed run mapped, probed when the mapping asks for it and server_url is unset.

Source

async fn run_ok( &self, what: &str, args: &[String], deadline: Duration, mutating: bool, ) -> Result<Finished, TransportError>

Run and settle everything but a successful exit: deadline, ceiling and a mapped failure.

Trait Implementations§

Source§

impl Transport for CliTransport

Source§

async fn call( &self, op: &Operation, params: &Params, body: Option<&Value>, deadline: Duration, ) -> Result<Value, TransportError>

Source§

async fn lifecycle(&self, v: Lifecycle) -> Result<String, TransportError>

Source§

async fn wait_idle( &self, session_id: &str, deadline: Duration, ) -> Result<WaitOutcome, TransportError>

Source§

async fn fetch_openapi(&self) -> Result<Value, TransportError>

Source§

async fn cli_version(&self) -> Result<String, TransportError>

Raw opencode --version stdout, trimmed, e.g. opencode v2.0.32.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more