pub trait HttpClient {
type Body: Serialize;
type ApiUrl: AsRef<str>;
type ApiKey: AsRef<str>;
// Required methods
fn api_url(&self) -> &Self::ApiUrl;
fn api_key(&self) -> &Self::ApiKey;
fn body(&self) -> &Self::Body;
// Provided methods
fn http_config(&self) -> Arc<HttpClientConfig> ⓘ { ... }
fn post(&self) -> impl Future<Output = ZaiResult<Response>> + Send { ... }
fn get(&self) -> impl Future<Output = ZaiResult<Response>> + Send { ... }
fn put(&self) -> impl Future<Output = ZaiResult<Response>> + Send { ... }
fn delete(&self) -> impl Future<Output = ZaiResult<Response>> + Send { ... }
}Expand description
Trait for HTTP clients that communicate with the Zhipu AI API.
Required Associated Types§
Required Methods§
fn api_url(&self) -> &Self::ApiUrl
fn api_key(&self) -> &Self::ApiKey
fn body(&self) -> &Self::Body
Provided Methods§
Sourcefn http_config(&self) -> Arc<HttpClientConfig> ⓘ
fn http_config(&self) -> Arc<HttpClientConfig> ⓘ
Get HTTP client configuration for this request
Override this method to provide custom configuration. Default implementation returns default configuration.
Sourcefn post(&self) -> impl Future<Output = ZaiResult<Response>> + Send
fn post(&self) -> impl Future<Output = ZaiResult<Response>> + Send
Sends a POST request to the API endpoint.
This method implements retry logic with exponential backoff and jitter.
It supports configuration through http_config method.
Sourcefn get(&self) -> impl Future<Output = ZaiResult<Response>> + Send
fn get(&self) -> impl Future<Output = ZaiResult<Response>> + Send
Sends a GET request to the API endpoint.
This method implements retry logic with exponential backoff and jitter.
It supports configuration through the http_config method.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".