pub struct OpencodeClientBuilder { /* private fields */ }Expand description
Builder for OpencodeClient.
Implementations§
Source§impl OpencodeClientBuilder
impl OpencodeClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
A builder defaulting to DEFAULT_BASE_URL with no auth or timeout.
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
Set the opencode server base URL (e.g. http://127.0.0.1:4096).
Sourcepub fn auth_from_env(self) -> Self
pub fn auth_from_env(self) -> Self
Attach HTTP Basic credentials derived from OPENCODE_SERVER_PASSWORD
(username "opencode"). A no-op when the variable is unset or empty.
This is the explicit opt-in for reading the environment; the request path never consults it implicitly.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Apply a per-request timeout to every call the client makes.
Applied per request, so it also constrains an injected
reqwest::Client that was built without a timeout.
Sourcepub fn reqwest_client(self, client: Client) -> Self
pub fn reqwest_client(self, client: Client) -> Self
Inject a pre-configured reqwest::Client (connection pools, proxies,
custom TLS). When omitted, a default client is built.
Sourcepub fn directory(self, directory: impl Into<String>) -> Self
pub fn directory(self, directory: impl Into<String>) -> Self
Scope every session endpoint (and the GET /event stream) to a project
directory.
opencode serve can manage several directories at once; without this the
server uses its own working directory. Set it to target a specific
project on a multi-directory server. Build one client per directory (the
clone is cheap) to drive several concurrently.
Sourcepub fn workspace(self, workspace: impl Into<String>) -> Self
pub fn workspace(self, workspace: impl Into<String>) -> Self
Scope every session endpoint (and the GET /event stream) to a
workspace identifier. See directory.
Sourcepub fn build(self) -> Result<OpencodeClient>
pub fn build(self) -> Result<OpencodeClient>
Build the OpencodeClient.
§Errors
Returns crate::Error::Transport if a default reqwest::Client must
be constructed and its builder fails.
Trait Implementations§
Source§impl Clone for OpencodeClientBuilder
impl Clone for OpencodeClientBuilder
Source§fn clone(&self) -> OpencodeClientBuilder
fn clone(&self) -> OpencodeClientBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more