pub struct OpencodeClient { /* private fields */ }Expand description
OpenCode API client aligned with official JS SDK request semantics.
Implementations§
Source§impl OpencodeClient
impl OpencodeClient
Sourcepub fn session(&self) -> SessionApi
pub fn session(&self) -> SessionApi
Returns session endpoint APIs (/session/...).
Sourcepub fn command(&self) -> CommandApi
pub fn command(&self) -> CommandApi
Returns command endpoint APIs.
Sourcepub fn project(&self) -> ProjectApi
pub fn project(&self) -> ProjectApi
Returns project endpoint APIs.
Sourcepub fn provider(&self) -> ProviderApi
pub fn provider(&self) -> ProviderApi
Returns provider endpoint APIs.
Sourcepub fn formatter(&self) -> FormatterApi
pub fn formatter(&self) -> FormatterApi
Returns formatter endpoint APIs.
Sourcepub fn instance(&self) -> InstanceApi
pub fn instance(&self) -> InstanceApi
Returns instance endpoint APIs.
Sourcepub fn control(&self) -> ControlApi
pub fn control(&self) -> ControlApi
Backward-compatible shorthand for TUI control endpoints.
Sourcepub async fn call_operation(
&self,
operation_id: &str,
options: RequestOptions,
) -> Result<ApiResponse>
pub async fn call_operation( &self, operation_id: &str, options: RequestOptions, ) -> Result<ApiResponse>
Execute any OpenCode operation by official operationId.
Sourcepub async fn call_operation_sse(
&self,
operation_id: &str,
options: RequestOptions,
) -> Result<SseStream>
pub async fn call_operation_sse( &self, operation_id: &str, options: RequestOptions, ) -> Result<SseStream>
Execute SSE operation by official operationId (global.event / event.subscribe).
Sourcepub async fn request_json(
&self,
method: Method,
path_template: &str,
options: RequestOptions,
) -> Result<ApiResponse>
pub async fn request_json( &self, method: Method, path_template: &str, options: RequestOptions, ) -> Result<ApiResponse>
Sends one HTTP request and returns a parsed JSON (or text) response envelope.
For 2xx responses:
204or empty body ->{}payload- valid JSON body -> parsed JSON
- non-JSON body -> string payload
For non-2xx responses, returns Error::Api with status and raw body.
Sourcepub async fn request_sse(
&self,
method: Method,
path_template: &str,
options: RequestOptions,
) -> Result<SseStream>
pub async fn request_sse( &self, method: Method, path_template: &str, options: RequestOptions, ) -> Result<SseStream>
Sends one HTTP request and parses the response as Server-Sent Events.
The parser supports:
- split UTF-8 across chunks
- multi-line
data:fields - trailing final lines without a terminating blank line
Trait Implementations§
Source§impl Clone for OpencodeClient
impl Clone for OpencodeClient
Source§fn clone(&self) -> OpencodeClient
fn clone(&self) -> OpencodeClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OpencodeClient
impl !RefUnwindSafe for OpencodeClient
impl Send for OpencodeClient
impl Sync for OpencodeClient
impl Unpin for OpencodeClient
impl UnsafeUnpin for OpencodeClient
impl !UnwindSafe for OpencodeClient
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