pub struct HttpTransport { /* private fields */ }Expand description
Low-level JSON-over-HTTP transport bound to one opencode base URL.
Cloning is cheap: the inner reqwest::Client is reference-counted.
Implementations§
Source§impl HttpTransport
impl HttpTransport
Sourcepub fn new(
client: Client,
base_url: impl Into<String>,
timeout: Option<Duration>,
auth: Option<BasicAuth>,
scope: Scope,
) -> Self
pub fn new( client: Client, base_url: impl Into<String>, timeout: Option<Duration>, auth: Option<BasicAuth>, scope: Scope, ) -> Self
Bind a transport to a base URL.
Trailing slashes on base_url are stripped so path builders can append
/-prefixed segments without producing //. The URL itself is validated
lazily by reqwest at send time; a malformed base surfaces as
Error::Transport.
Sourcepub fn scope(&self) -> &Scope
pub fn scope(&self) -> &Scope
The directory / workspace scoping applied to every session URL and
the GET /event stream this transport builds.
Sourcepub fn join(&self, path: &str) -> String
pub fn join(&self, path: &str) -> String
Join an arbitrary path (leading slash optional) onto the base URL. Backing helper for the client’s raw escape hatch; the path is used verbatim (not segment-encoded).
Sourcepub fn session_create_url(&self) -> String
pub fn session_create_url(&self) -> String
URL for POST /session (session creation).
Sourcepub fn prompt_async_url(&self, session_id: &str) -> String
pub fn prompt_async_url(&self, session_id: &str) -> String
URL for POST /session/{sessionID}/prompt_async.
Sourcepub fn messages_url(
&self,
session_id: &str,
limit: Option<u64>,
before: Option<&str>,
) -> String
pub fn messages_url( &self, session_id: &str, limit: Option<u64>, before: Option<&str>, ) -> String
URL for GET /session/{sessionID}/message, optionally paginated with the
limit and before query parameters used for reconciliation polling.
Sourcepub fn permission_url(&self, session_id: &str, permission_id: &str) -> String
pub fn permission_url(&self, session_id: &str, permission_id: &str) -> String
URL for POST /session/{sessionID}/permissions/{permissionID}.
Sourcepub fn event_url(&self) -> String
pub fn event_url(&self) -> String
URL for the GET /event SSE stream, with any configured Scope
applied as directory / workspace query parameters.
Sourcepub fn event_request(&self) -> RequestBuilder
pub fn event_request(&self) -> RequestBuilder
A RequestBuilder for the GET /event SSE stream on this transport’s
Client, with the configured base URL, Scope, and auth applied.
Hand it to crate::sse::EventStream::from_request to open an
authenticated event stream that reuses this transport’s connection pool.
No per-request timeout is applied, since the stream is long-lived.
Sourcepub async fn request_json<R: DeserializeOwned>(
&self,
method: Method,
url: &str,
body: Option<Value>,
) -> Result<R>
pub async fn request_json<R: DeserializeOwned>( &self, method: Method, url: &str, body: Option<Value>, ) -> Result<R>
Send a request and deserialize the JSON response body into R.
Trait Implementations§
Source§impl Clone for HttpTransport
impl Clone for HttpTransport
Source§fn clone(&self) -> HttpTransport
fn clone(&self) -> HttpTransport
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more